creating names in plpgsql-functions - Mailing list pgsql-general

From Lieven Van Acker
Subject creating names in plpgsql-functions
Date
Msg-id 3AEAE233.70AE71DB@elisa.be
Whole thread Raw
Responses Re: creating names in plpgsql-functions
List pgsql-general
Hi,

is there a way to make a name in a plpgsql procedure dynamic? I want to
do something like this:

CREATE FUNCTION create_admin(BPCHAR)
RETURNS BPCHAR AS '
        DECLARE
                seqname name;
                a alias for $1;
        BEGIN
                insert into admin(adminid)
                values (a);

                seqname := a || ''_seq'';

                create sequence seqname;

                return seqname;
        END;'
LANGUAGE 'plpgsql';

Calling this function returns

SELECT create_admin('TS');
ERROR:  parser: parse error at or near "$1"

Thanks,

Lieven


pgsql-general by date:

Previous
From: Viacheslav N Tararin
Date:
Subject: PRIMARY KEY constraint questions.
Next
From: Feite Brekeveld
Date:
Subject: Very long VACUUM time ...