Re: context in plpgsql functions

From: elein <elein(at)varlena(dot)com>
To: Gianni Mariani <gianni(at)mariani(dot)ws>, pgsql-general(at)postgresql(dot)org
Cc: elein(at)varlena(dot)com
Subject: Re: context in plpgsql functions
Date: 2003-05-16 23:27:13
Message-ID: 200305161627.13742.elein@varlena.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


You can do this with plpython. There is a brief write up about
it at http://www.varlena.com/GeneralBits/23.html

There is one trick to it :-)

--elein

On Friday 16 May 2003 11:46, Gianni Mariani wrote:
> I've been using PostgreSQL 7.3.2.
>
> What, if any, way is there to share a context (global rowtype variable)
> between plpgsql functions ?
>
> Can row types be passed as parameters ? (I seem to have had trouble
> doing that)
>
> e.g.
>
> A transaction that looks like:
>
> BEGIN;
> select FindContext(5432);
> select SomeRandomFunction('111');
> COMMIT;
>
>
> The functions would look somthing like:
>
> CREATE or replace FUNCTION FindContext(int4) RETURNS int4 AS
> '
> DECLARE
> w_key alias for $1;
> w_context context%ROWTYPE;
> BEGIN
>
> SELECT INTO w_context * FROM contecxt WHERE key = w_key;
>
> -- I want to access w_context in a different method
>
> RETURN 1;
>
> END;
> '
> LANGUAGE 'plpgsql';
>
>
> CREATE or replace FUNCTION SomeRandomFunction(int4) RETURNS int4 AS
> '
> DECLARE
> w_stuff alias for $1;
> w_context context%ROWTYPE; -- ??????????????
> BEGIN
>
> update sometable set key = w_context.key where yadda = w_stuff;
>
> RETURN 1;
>
> END;
> '
> LANGUAGE 'plpgsql';
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>

--
=============================================================
elein(at)varlena(dot)com Database Consulting www.varlena.com
PostgreSQL General Bits http:/www.varlena.com/GeneralBits/
"Left foot, right foot, left foot, breathe.
Right foot, left foot, right foot, breathe." --Father Tom

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Doug McNaught 2003-05-16 23:30:32 Re: Result set return to Coldfusion MX?
Previous Message Avi Schwartz 2003-05-16 23:24:07 Result set return to Coldfusion MX?