Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group