Re: Question about SQL Control Structure(if then, for loop)
От | Michael Artz |
---|---|
Тема | Re: Question about SQL Control Structure(if then, for loop) |
Дата | |
Msg-id | e9c163070605180219n4d78faa1r22992bb622a56892@mail.gmail.com обсуждение исходный текст |
Ответ на | Question about SQL Control Structure(if then, for loop) (Jay Chiu <jaychiu@ureach.com>) |
Ответы |
Re: Question about SQL Control Structure(if then, for loop)
|
Список | 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
В списке pgsql-sql по дате отправления: