| From: | "Michael Artz" <mlartz(at)gmail(dot)com> |
|---|---|
| To: | jaychiu(at)ureach(dot)com |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Question about SQL Control Structure(if then, for loop) |
| Date: | 2006-05-18 09:19:44 |
| Message-ID: | e9c163070605180219n4d78faa1r22992bb622a56892@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
If you're control is that simple, you can write similar statements in pure
SQL:
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
SELECT 'test' FROM
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)
> ^
SELECT 'test' FROM testtable LIMIT 1;
Without knowing about what you want to do, I can't guarantee that that will
suffice and/or be efficient. If it gets much more complicated, you might
have to go to some procedural language (PL/PGSQL, PL/Perl, etc). Just
remember that SQL is set-based, not procedural.
-Mike
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Artz | 2006-05-18 09:21:17 | Re: Question about SQL Control Structure(if then, for loop) |
| Previous Message | Dirk Jagdmann | 2006-05-18 07:40:05 | Re: table constraint + INSERT |