From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Marek Lewczuk <newsy(at)lewczuk(dot)com> |
Cc: | fryk <fryk(at)tlen(dot)pl>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Client's variables |
Date: | 2005-01-20 21:06:15 |
Message-ID: | 41F01D47.9080205@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Marek Lewczuk wrote:
> fryk napisał(a):
>
>> Hi,
>>
>> How to set such variable after (during?) client connection (PHP)?
>>
>> I want to use it in view - so view could depends on it:
>>
>> If I could set client's variable i.e. MY_VAR='hello' then I could do
>> something like this:
>>
>> CREATE VIEW my_view AS SELECT * FROM pg_tables WHERE tablename ~* (SELECT
>> MY_VAR FROM ???)
>
>
> You have (at least) two choices. First is to use temporary table, where
> you can store anything you wish and it will be visible and available for
> current connection/session.
>
> Read more:
> http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html
>
> Another solution is to use plperl - this is more flexible then the first
> one. plperl supports global values - go to:
> http://www.postgresql.org/docs/8.0/interactive/plperl-global.html
> and see examples set_var and get_var.
Or, in the attached file, I've used pltcl. Again, it uses global
variables to store session data. If you know TCL you may be able to
improve on these functions since I more or less cut and paste these
together.
--
Richard Huxton
Archonet Ltd
Attachment | Content-Type | Size |
---|---|---|
session_functions.sql | text/x-sql | 1.2 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Ian Barwick | 2005-01-20 22:45:28 | Re: How to manually insert an UTF-8 character into an SQL statement? |
Previous Message | Tino Wildenhain | 2005-01-20 21:00:20 | Re: Unique Index |