Обсуждение: psql batch file question

Поиск
Список
Период
Сортировка

psql batch file question

От
"Matt Doughty"
Дата:

Hi List,

 

I’m trying to write a batch file that executes a query in PostgreSQL. Depending on the output of the query, the batch file does one of two things, jumps to a line that has a command to export a table from PostgreSQL, or calls another batch file, which copies some files.

 

What proving difficult is how to handle the output of the query. Should I declare the output as a variable and somehow use that? Currently, the output is:

 

Expanded display is on.

-[ RECORD 1 ]------

ta_id_vacia | DATA

 

I’d like to be able to use ‘DATA’ as a variable to call one command or the other.

 

Has anybody got any ideas?

 

Thanks!

 

Matt

 

PS. Below I’ve copied the current state of the bat.

 

 

 

 

rem %1 database - %2 scheme

 

echo. IF \x \\select count(*) from function01('%2', '[table]') | psql %1 [user_name]==DATA goto data

echo.

 

:copy

echo. call copy_bat.bat [table]

 

:data

echo. pgsql2shp.exe -h localhost -u [user_name] -f [dbase_name] "[scheme]".[table] querystring

:end

 

 

 

 

Matt Doughty

GEOGRAMA S.L.

Tel.:  +34 945 13 13 72    652 77 14 15

Fax: +34 945 23 03 40

www.geograma.com

 

 

Вложения

Re: psql batch file question

От
"Joshua D. Drake"
Дата:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 11 Dec 2007 17:50:14 +0100
"Matt Doughty" <matt.doughty@geograma.com> wrote:

> Hi List,
> 
>  
> 
> I'm trying to write a batch file that executes a query in PostgreSQL.
> Depending on the output of the query, the batch file does one of two
> things, jumps to a line that has a command to export a table from
> PostgreSQL, or calls another batch file, which copies some files.

Use perl, python, mono/c#, java, pl/sh ... you have a wealth of various
easy to use APIs :)

Joshua D. Drake


- -- 
The PostgreSQL Company: Since 1997, http://www.commandprompt.com/ 
Sales/Support: +1.503.667.4564   24x7/Emergency: +1.800.492.2240
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
SELECT 'Training', 'Consulting' FROM vendor WHERE name = 'CMD'


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHXsJ6ATb/zqfZUUQRAoooAJ9Um39yEM803oPdz99FR9cl7p14dACfTJbN
xEsrGGiRJXANHKbEpesD8o4=
=zuI9
-----END PGP SIGNATURE-----