Skip site navigation (1) Skip section navigation (2)

Re: creating names in plpgsql-functions

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Lieven Van Acker <lieven(at)elisa(dot)be>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: creating names in plpgsql-functions
Date: 2001-04-29 05:10:16
Message-ID: Pine.BSF.4.21.0104282209210.33889-100000@megazone23.bigpanda.com (view raw or flat)
Thread:
Lists: pgsql-general
Under 7.0.x and earlier, no.
Under 7.1, you can use execute to execute a string which
could have dynamic bits (replace create sequence seqname;
with execute ''create sequence '' || seqname;)


On Sat, 28 Apr 2001, Lieven Van Acker wrote:

> 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
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
> 
> http://www.postgresql.org/search.mpl
> 


In response to

pgsql-general by date

Next:From: Justin CliftDate: 2001-04-29 05:20:23
Subject: Re: JDBC speed question.
Previous:From: Jeff WaughDate: 2001-04-29 05:04:18
Subject: Re: Re: crypt(table.field) ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group