Search Postgresql Archives

Re: conditionally terminate psql script

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

 



On Mon, Dec 17, 2018 at 2:07 PM <hamann.w@xxxxxxxxxxx> wrote:
many thanks -- too bad I am still using 9.3


not sure if it has been mentioned in the thread so far. But according to the docs, 9.3 psql does support the \gset command. So you should be able to do something like this:

select case when exists (select 1 from pg_namespace where nspname='tf')
            then '\echo schema tf exists \\ \q'
            else '\echo schema does not exist -- creating ...'
       end as cmd\gset
:cmd

create schema tf;
create table tf.i(i int);


[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