| From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: functions behaviours |
| Date: | 2006-04-04 13:10:38 |
| Message-ID: | 20060404131038.GD29229@webserv.wug-glas.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
am 04.04.2006, um 15:02:19 +0200 mailte ycrux(at)club-internet(dot)fr folgendes:
> Hi All!
>
> I'm wondering if there is an elegant way to add simple behaviours to stored Postgres functions.
>
> 1. First, what I want to get here is a function which orders their
> results columns in ASC at one time and in DESC next time it is called.
> Something like that:
>
> CREATE FUNCTION sort_swap(integer) RETURNS SETOF atype AS '
>
> sort_type ALIAS FOR $1;
> row atype;
>
> RETURN;
> ' LANGUAGE plpgsql;
>
> What I want here is a function without the sort_type parameter.
Write 2 functions, one for ASC and one for DESC?
> 2. Second, is it possible to give a function a parameter which correspond to a table name?
>
> CREATE FUNCTION function_with_behaviours(integer) RETURNS SETOF atype AS '
>
> table_name ALIAS FOR $1;
> row atype;
>
> SELECT INTO row * FROM table_name;
>
> RETURN row;
> ' LANGUAGE plpgsql;
>
> In that case, how to dynamically adapt atype to the be table_name%ROWTYPE ?
HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
| From | Date | Subject | |
|---|---|---|---|
| Next Message | patrick | 2006-04-04 13:25:37 | Re: recover from base directory? |
| Previous Message | Courtenay Teska | 2006-04-04 13:03:46 | Re: giving users access to specific databases |