From: Jay Chiu <jaychiu@ureach.com>
To: pgsql-sql@postgresql.org
Cc: jaychiu@ureach.com
Subject: Question about SQL Control Structure(if then, for loop)
Date: Tue, 16 May 2006 21:51:45 -0400
Message-ID: <200605170151.VAA30155@www20.ureach.com> (raw)
Hello,
I am new to PostgreSQL and want to use the IF-THEN; LOOP
statements in my SQL command file. Thus I may use psql -f cfile
to exceute.
However I always got syntax error on if/for in psql. For
example:
RDM=# for i in 1 .. 10 loop
RDM-# select "test"
RDM-# end loop;
ERROR: syntax error at or near "for" at character 1
LINE 1: for i in 1 .. 10 loop
RDM=# if exits ( select * from testtable)
RDM-# then
RDM-# select "TEST"
RDM-# ;
ERROR: syntax error at or near "if" at character 1
LINE 1: if exits ( select * from testtable)
^
Can someone tell me how to use if/for in psql? The document
shows the control structures in the PL/pgSQL section. Must I use
if/for inside some procedure/function?
Thanks a lot.
Jay
________________________________________________
Get your own "800" number
Voicemail, fax, email, and a lot more
http://www.ureach.com/reg/tag
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: jaychiu@ureach.com
Subject: Re: Question about SQL Control Structure(if then, for loop)
In-Reply-To: <200605170151.VAA30155@www20.ureach.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox