How to get result of a query from MS DOS batch script or delete file from plpgsq - Mailing list pgsql-cygwin

From Pham Luu Hung
Subject How to get result of a query from MS DOS batch script or delete file from plpgsq
Date
Msg-id BAY99-F42wiMzx3zNwB00040f8e@hotmail.com
Whole thread Raw
List pgsql-cygwin
<div style="background-color:"><div><div class="RTE">Hi all</div><div class="RTE"> </div><div class="RTE">I'm writing a
MSDOS batch script to delete some expired rows from my PostgreSQL DB and also some associated file (which full path is
storedin DB).  In order to fulfil that, I have to get the date and path from DB, and delete the expired row as well as
thefile associated with that row. So now 2 have to approaches:</div><div class="RTE"> </div><div class="RTE">1. Write
a plpgsqlscrip and run it by psql. Inside the plpgsql script I have to delete the file in hard disk, but till now I
couldnot find any way to do that. I do not know whether plpgsql can support some type of file manipulation? </div><div
class="RTE"> </div><divclass="RTE">2. Delete the file from MS DOS batch script ( it is easier), but I have to pass the
queryresult (which is mostly an array) to the MS DOS batch script.</div><div class="RTE"> </div><div class="RTE">For
thesecond approach, my first try is to output the query result to a text file </div><div class="RTE">(eg: bash -c "psql
-d DBname-c "select COLUMN_name from A_table WHERE...;" > result.txt")</div><div class="RTE">but the text file is
sucha complicated file with name of column and some symbol ----- so it is difficult to extract the result.</div><div
class="RTE"> </div><divclass="RTE">So do you have any suggestion for my problem? Is there any way to delete file within
theplpgsql block, or sending query result to MS DOS script in a convenient way for being  processed.</div><div
class="RTE"> </div><divclass="RTE">Thank you very much. </div><div class="RTE"> </div><div
class="RTE">Regards</div><divclass="RTE"> </div><div class="RTE">Pham Luu Hung</div></div></div><br clear="all" /><hr
/>Addphotos to your e-mail with <a href="http://g.msn.com/8HMBEN/2746??PS=">MSN 8.</a> Get 2 months FREE*. 

pgsql-cygwin by date:

Previous
From: Ben Ramsey
Date:
Subject: Adding long text to a text field generates an error
Next
From: Patrick Samson
Date:
Subject: Re: Initdb failing when installing Postgre on Cygwin