Search Postgresql Archives

Re: Client's variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


You decide what is the best solution for your needs.


In Polish:
Masz dwa wyjÅcia. Pierwszy wykorzystaÄ tablice tymczasowÄ, w ktÃrej moÅesz trzymaÄ co chcesz. BÄdzie ona widoczna tylko dla jednego uÅytkownika w obecnej sesji/poÅÄczeniu. Zobacz wiÄcej:
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html


Drugie rozwiÄzanie to skorzystaÄ z plperl'a - to jest bardziej elastyczne rozwiÄzanie. Plperl posiada moÅliwoÅÄ tworzenia globalnych zmiennych. Zobacz wiÄcej:
http://www.postgresql.org/docs/8.0/interactive/plperl-global.html
Masz tam przykÅadowe funkcje, ktÃre moÅesz ÅmiaÅo wykorzystaÄ.


Sam zdecyduj co jest lepszym rozwiÄzaniem w Twojej aplikacji.


ML



---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux