function to create a table

Started by Diana Cionoiuabout 25 years ago1 messagesgeneral
Jump to latest
#1Diana Cionoiu
diana@softwaresolutions.ro

Good day,
I have a problem with plpgsql, whitch is really strange for me.
I wanna create a table, with a function like this :

CREATE FUNCTION domenii(text,text,text)
RETURNS boolean
AS 'DECLARE
legi ALIAS FOR $2;
BEGIN
CREATE TABLE legi(idc serial, idp char(10), nume char(50), PRIMARY
KEY(idc));
RETURN ''t'';
END;'
LANGUAGE 'plpgsql';

the error message from psql is :

select domenii('gigi','gigi1','gigi2');
ERROR: parser: parse error at or near "$1"

and the postgres error message is

010330.08:16:53.385 [9931] ERROR: parser: parse error at or near "$1"
010330.08:16:53.385 [9931] DEBUG: Last error occured while executing
PL/pgSQL function domenii
010330.08:16:53.386 [9931] DEBUG: line 4 at SQL statement

my question is.
Why is asking me about $1 wenn i don't have this in my function, it seems to be a problem with create table.
Thanks you very much.

Diana Cionoiu