Unix Technical Forum

how to echo SQL commands in the output of a script

This is a discussion on how to echo SQL commands in the output of a script within the pgsql Novice forums, part of the PostgreSQL category; --> I have a number of sql scripts which I execute using psql -f I can easily redirect the output ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 09:15 PM
Gino Lucrezi
 
Posts: n/a
Default how to echo SQL commands in the output of a script

I have a number of sql scripts which I execute using psql -f

I can easily redirect the output for logging and archival.
However, psql will only display the result of each SQL statement, and
not the actual SQL statement.
While this is fine for most purposes, sometimes I'd rather have both
the SQL statement and its output on the same file.

Is there a way to have it?

In case I wasn't clear... did you ever do any batch programming under
MS-DOS? I need the equivalent of the ECHO ON command

Thanks in advance

Gino

Gino Lucrezi
Penta Consulting Services Srl
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 09:15 PM
Andreas Kretschmer
 
Posts: n/a
Default Re: how to echo SQL commands in the output of a script

begin Gino Lucrezi <gino-pgadmin@lucrezi.net> wrote:
> I have a number of sql scripts which I execute using psql -f


> I can easily redirect the output for logging and archival.
> However, psql will only display the result of each SQL statement, and
> not the actual SQL statement.
> While this is fine for most purposes, sometimes I'd rather have both
> the SQL statement and its output on the same file.


> Is there a way to have it?


I think, you search the '-e' - Option for psql.



> In case I wasn't clear... did you ever do any batch programming under
> MS-DOS? I need the equivalent of the ECHO ON command


What for the hell is MS-DOS?



> Thanks in advance


Please ;-)



end
Andreas
--
Diese Message wurde erstellt mit freundlicher Unterstützung eines freilau-
fenden Pinguins aus artgerechter Freilandhaltung. Er ist garantiert frei
von Micro$oft'schen Viren. (#97922 http://counter.li.org) GPG 7F4584DA
Was, Sie wissen nicht, wo Kaufbach ist? Hier: N 51.05082°, E 13.56889° ;-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 09:15 PM
George Weaver
 
Posts: n/a
Default Re: how to echo SQL commands in the output of a script

Does the psql option -e not provide what you're looking for?

George

----- Original Message -----
From: "Gino Lucrezi" <gino-pgadmin@lucrezi.net>
To: <pgsql-novice@postgresql.org>
Sent: Friday, December 17, 2004 6:48 AM
Subject: [NOVICE] how to echo SQL commands in the output of a script


>I have a number of sql scripts which I execute using psql -f
>
> I can easily redirect the output for logging and archival.
> However, psql will only display the result of each SQL statement, and
> not the actual SQL statement.
> While this is fine for most purposes, sometimes I'd rather have both
> the SQL statement and its output on the same file.
>
> Is there a way to have it?
>
> In case I wasn't clear... did you ever do any batch programming under
> MS-DOS? I need the equivalent of the ECHO ON command
>
> Thanks in advance
>
> Gino
>
> Gino Lucrezi
> Penta Consulting Services Srl
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>



---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 09:16 PM
Gino Lucrezi
 
Posts: n/a
Default Re: how to echo SQL commands in the output of a script

On Fri, 17 Dec 2004 20:30:55 +0100, Andreas Kretschmer
<andreas_kretschmer@despammed.com> wrote:

>I think, you search the '-e' - Option for psql.


You think right.. I should have searched more (it was right under my
nose)

>> In case I wasn't clear... did you ever do any batch programming under
>> MS-DOS? I need the equivalent of the ECHO ON command

>
>What for the hell is MS-DOS?


:-)

Gino

Gino Lucrezi
Penta Consulting Services Srl
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:51 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com