Re: sql files in psql ?

From: Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: sql files in psql ?
Date: 2010-05-31 21:51:28
Message-ID: 4C042F60.6050301@vmsinfo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 05/31/2010 05:14 PM, Tom Lane wrote:
> Mariateresa L<mariateresa(dot)ll(at)bresciaonline(dot)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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jeanne Louize Emygdio 2010-06-01 12:16:59 Invitation to connect on LinkedIn
Previous Message Joe Brenner 2010-05-31 21:37:55 Re: sql files in psql ?