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

Re: plpgsql ?

From: Kovacs Zoltan Sandor <tip(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu>
To: guard <guard(at)ficnet(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql ?
Date: 2000-12-20 20:51:26
Message-ID: Pine.LNX.4.05.10012202147060.29810-100000@pc10.radnoti-szeged.sulinet.hu (view raw or flat)
Thread:
Lists: pgsql-sql
> CREATE FUNCTION autono (text,text) RETURNS text AS '
>   DECLARE
>     a1 ALIAS FOR $1;
>     a2 ALIAS FOR $1;
>     ret_val text;
>   BEGIN
>     select tna  into ret_val from a1  where pamt_no=a2;
> 
>   RETURN ret_val;
> END;' LANGUAGE 'plpgsql'
> 
> 
> error run  "   select tna  into ret_val from a1  where pamt_no=a2;    "
You cannot give a table name as an argument. You should write different
SELECTs for different tables, like this:

if a1 = ''dummy1'' then select tna into ret_val from dummy1 where
pamt_no=a2; end if;

if a1 = ''dummy2'' then select tna into ret_val from dummy2 where
pamt_no=a2; end if;

...

And so on. Unfortunately... :-)

Zoltan



In response to

  • plpgsql ? at 2000-12-20 03:40:29 from guard

pgsql-sql by date

Next:From: Jie LiangDate: 2000-12-21 00:00:15
Subject: Re: How to set autocommit on/off
Previous:From: Stephan SzaboDate: 2000-12-20 18:59:45
Subject: Re: how to alter/drop check contraint?

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