Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to do looping if else in SQL

1021864May 31 2017 — edited Jun 2 2017

Hi All,

Because of project limitations, I cant write PLSQL and hence need to write login in SQL only. I would like to know how can we do looping and if else in SQL statement. I cam across

looping from blog How to do a loop in Oracle SQL ,

with t as
(
  select date '2008-06-01' d1, date '2008-06-10' d2 from dual
)
select d1 + i days
  from t, xmltable('for $i in 0 to xs:int(D) return $i' passing xmlelement(d, d2-d1)
                                                        columns i integer path '.')

So, whi

but would like to know how to do if else and exit from loop. If i am able to understand the above, then may be i can try to write my logic. Could anyone please advise with some explanation about the above SQL

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 30 2017
Added on May 31 2017
19 comments
1,400 views