Search Postgresql Archives

Re: SQL select return into PSQL variables.

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

 



On Thu, Feb 18, 2010 at 10:33 AM, Little, Douglas <DOUGLAS.LITTLE@xxxxxxxxxx> wrote:

psql

orbitz=# \!testvar=1234

orbitz=# \!export testvar

orbitz=# \!echo $testvar

1234

orbitz=# \q

-bash-3.00$ echo $testvar                                                                                                                                    

1234

What shell are you using that allows a child process to alter the parent process' environment?  ohhhhh. you must be on windows....  this is not normal unix behavior: the child process (psql) cannot alter the parent (shell) environment, and every \! command you run fires a new subshell.  On unix you see this:

[yertle]% psql
Timing is on.
Welcome to psql 8.3.9 (server 8.3.7), the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

khera=> \!testvar=1234
khera=> \!export testvar
khera=> \!echo $testvar

khera=> \q
[yertle]% echo $testvar
testvar: Undefined variable.
[yertle]% 


[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