The following bug has been logged online:
Bug reference: 1875
Logged by: Byron
Email address: byron.hammond@westnet.com.au
PostgreSQL version: 8.0.3
Operating system: Windows XP
Description: Function parameter names clash with table column names
Details:
-----------------------------
Error Details from PgAdminIII
-----------------------------
ERROR: syntax error at or near "$1" at character 28
QUERY: INSERT INTO test_table_0 ( $1 , $2 , $3 ) VALUES ( $4 , $5 , $6
)
CONTEXT: PL/pgSQL function "test_function_0" line 2 at SQL statement
------------
Problem Code
------------
CREATE TABLE test_table_0 (
a varchar(255),
b varchar(255),
c varchar(255)
);
CREATE OR REPLACE FUNCTION test_function_0(a varchar, b varchar, c varchar)
RETURNS INTEGER AS $$
BEGIN
INSERT INTO test_table_0 (a, b, c) VALUES (a, b, c);
RETURN 1;
END
$$ LANGUAGE 'plpgsql';
SELECT test_function_0('a', 'b', 'c');
DROP FUNCTION test_function_0(varchar, varchar, varchar);
DROP TABLE test_table_0;
-------------------
Additional Comments
-------------------
It appears in this case that the parameter names of the
function cannot be the same as the column names used
by the INSERT statement -- clashes.