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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-sql by date

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