function to create a table - Mailing list pgsql-general

From diana@softwaresolutions.ro
Subject function to create a table
Date
Msg-id 200103300609.f2U69Uf16249@softwaresolutions.ro
Whole thread Raw
List pgsql-general
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


pgsql-general by date:

Previous
From: Maurizio Ortolan
Date:
Subject: Error in the date field (with NULL value...).Thanks!
Next
From: "Vilson farias"
Date:
Subject: Re: enable pl/pgsql in postgres from postgres-server-7.0.3-2 RPM