Hi all
 
I'm writing a MS DOS batch script to delete some expired rows from my PostgreSQL DB and also some associated file (which full path is stored in DB).  In order to fulfil that, I have to get the date and path from DB, and delete the expired row as well as the file associated with that row. So now 2 have to approaches:
 
1. Write a plpgsql scrip and run it by psql. Inside the plpgsql script I have to delete the file in hard disk, but till now I could not find any way to do that. I do not know whether plpgsql can support some type of file manipulation? 
 
2. Delete the file from MS DOS batch script ( it is easier), but I have to pass the query result (which is mostly an array) to the MS DOS batch script.
 
For the second approach, my first try is to output the query result to a text file
(eg: bash -c "psql -d DBname -c "select COLUMN_name from A_table WHERE...;" > result.txt")
but the text file is such a complicated file with name of column and some symbol ----- so it is difficult to extract the result.
 
So do you have any suggestion for my problem? Is there any way to delete file within the plpgsql block, or sending query result to MS DOS script in a convenient way for being  processed.
 
Thank you very much.
 
Regards
 
Pham Luu Hung


Add photos to your e-mail with MSN 8. Get 2 months FREE*.