Thread: Constaints
Is there anyway to declare a constant that you can then use within a postgresql 'session', i am connecting from a PHP based application and trying to integrate another. What I want to be able to do is setup a rule on another table so that whenever a query is run on the table it appends another value to the query. i.e i want to be able to do: 'SET someconstant an_id=1;' Then with a rule, running: SELECT * FROM a_table would become: SELECT * FROM a_table WHERE id=a_id is this possible? Thanks Jake
On Sun, Dec 05, 2004 at 16:55:33 +0000, Jake Stride <nsuk@users.sourceforge.net> wrote: > Is there anyway to declare a constant that you can then use within a > postgresql 'session', i am connecting from a PHP based application and > trying to integrate another. > > What I want to be able to do is setup a rule on another table so that > whenever a query is run on the table it appends another value to the query. > > i.e i want to be able to do: > > 'SET someconstant an_id=1;' > > Then with a rule, running: > > SELECT * FROM a_table > > would become: > > SELECT * FROM a_table WHERE id=a_id > > is this possible? At the worst you should be able to use a table with a row for each session that includes the value to be used for each session.
Bruno Wolff III wrote: >On Sun, Dec 05, 2004 at 16:55:33 +0000, > Jake Stride <nsuk@users.sourceforge.net> wrote: > > >>Is there anyway to declare a constant that you can then use within a >>postgresql 'session', i am connecting from a PHP based application and >>trying to integrate another. >> >> > >At the worst you should be able to use a table with a row for each session >that includes the value to be used for each session. > > Would this be a postgresql session? If so how do I go about accessing it from a query/setting the value of it? I have looked at set authorization but I don't think this is where I should be looking! Thanks Jake
On 12/5/2004 12:48 PM, Jake Stride wrote: > Bruno Wolff III wrote: > >>On Sun, Dec 05, 2004 at 16:55:33 +0000, >> Jake Stride <nsuk@users.sourceforge.net> wrote: >> >> >>>Is there anyway to declare a constant that you can then use within a >>>postgresql 'session', i am connecting from a PHP based application and >>>trying to integrate another. >>> >>> >> >>At the worst you should be able to use a table with a row for each session >>that includes the value to be used for each session. >> >> > Would this be a postgresql session? If so how do I go about accessing it > from a query/setting the value of it? I have looked at set authorization > but I don't think this is where I should be looking! PostgreSQL does not have userland session variables. You would have to write some custom set/get functions in a procedural language that is capable of holding global data across function calls (like PL/Tcl). Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #================================================== JanWieck@Yahoo.com #
On Sun, Dec 05, 2004 at 17:48:32 +0000, Jake Stride <nsuk@users.sourceforge.net> wrote: > Would this be a postgresql session? If so how do I go about accessing it > from a query/setting the value of it? I have looked at set authorization > but I don't think this is where I should be looking! At the start of each session you use an insert or update to update the table with the values using the session id (process id) as the key. Your views can refer to this table and the session id to get the appropiate value.
On 2004-12-05, Jan Wieck <JanWieck@Yahoo.com> wrote: > PostgreSQL does not have userland session variables. You would have to > write some custom set/get functions in a procedural language that is > capable of holding global data across function calls (like PL/Tcl). You can fake session variables by using constant-returning functions defined in the per-session temporary namespace. -- Andrew, Supernews http://www.supernews.com - individual and corporate NNTP services