| From: | Kyle Bateman <kyle(at)actarg(dot)com> |
|---|---|
| To: | Stef telford <stef(at)chronozon(dot)dyndns(dot)org> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Clarified Question |
| Date: | 2000-05-24 22:44:44 |
| Message-ID: | 392C5B5C.64CCAA78@actarg.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
>
> How can I create a function that will take in two variables and return
> an integer, when one of the variables is the tablename ?!
>
> I have tried :
>
> create function tst_func(text, varchar(16))
> as
> 'BEGIN
> result=select max(history_id)+1 from $1
> where client_id = $2;
> return result;
> END;'
>
This kind of thing does work in pltcl but AFAIK you can't specify a table name
with a parameter in plpgsql. This may give you the idea:
create function myfunc(text,text) returns result as '
set res [spi_exec "select f1 from $1 where f2 = \'$2\']
return $res
' language 'pltcl';
| Attachment | Content-Type | Size |
|---|---|---|
| kyle.vcf | text/x-vcard | 291 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ross J. Reedstrom | 2000-05-24 23:03:25 | Re: possible bug with group by? |
| Previous Message | Patrick Welche | 2000-05-24 22:40:57 | Re: [HACKERS] |