Re: sql files in psql ? - Mailing list pgsql-novice

From Mladen Gogala
Subject Re: sql files in psql ?
Date
Msg-id 4C042F60.6050301@vmsinfo.com
Whole thread Raw
In response to Re: sql files in psql ?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
On 05/31/2010 05:14 PM, Tom Lane wrote:
> Mariateresa L<mariateresa.ll@bresciaonline.it>  writes:
>
>> ... I want to pack everything in a nice shell script,
>> with proper error control, automated file shuffling,
>> predefined queries in text files and so on, but I cannot
>> convince psql that the SQL commands (select, insert or
>> copy...) it has to handle come from a file.
>> I can submit  ("\i filename" or "psql --file filename")
>> files that contains commands, eg starting with "\" but
>> psql does not understand the same sintax if tne file
>> contains a simple "SELECT * FROM tablex".
>>
> Really?  Works for most people.
>

The problem is probably in an un-escaped "*" character in the script.
Shell will translate that into the list of files and really mess up the
underlying SQL command.  I must admit, though, that the problem
description is a bit vague and that without a much more precise script
template and the resulting error message, I am unable to provide any
more useful information. The OP talks both about psql and \i command, as
well as the shell script. I suspect that therein lies the reason for the
fatal combination.


--
Mladen Gogala
Sr. Oracle DBA
1500 Broadway
New York, NY 10036
(212) 329-5251
www.vmsinfo.com
The Leader in integrated Media Intelligence Solutions


pgsql-novice by date:

Previous
From: Joe Brenner
Date:
Subject: Re: sql files in psql ?
Next
From: Jeanne Louize Emygdio
Date:
Subject: Invitation to connect on LinkedIn