creating names in plpgsql-functions

From: Lieven Van Acker <lieven(at)elisa(dot)be>
To: pgsql-general(at)postgresql(dot)org
Subject: creating names in plpgsql-functions
Date: 2001-04-28 15:30:59
Message-ID: 3AEAE233.70AE71DB@elisa.be
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message The Hermit Hacker 2001-04-28 16:11:18 Re: Very long VACUUM time ...
Previous Message Patrick Dubois 2001-04-28 15:00:30 Re: new PostgreSQL user question