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!

Run second sql statement only if first sql statement is null.

mlov83Nov 13 2010 — edited Nov 13 2010
Hey guys I seem to have a mental block here. I have two sql statements. I would like the second to run only if the first sql statement is null.I know i can potentially use PLsql but would really like to see if i can do this with straight up sql. Your responses are very very appreciated.
here is the first sql
  Select     ft.fund_code, 
             ft.orgn_code, 
             ft.acct_code, 
             ft.amount, 
             fb.owner_pidm, 
             ft.prog_code      
      from ftrbremb fb , ftcractg ft
      where fb.doc_code = 'TR000038'
      and fb.ftpbport_id = ft.ftpbport_id
second sql statement
     Select ft.fund_code, 
             ft.orgn_code, 
             ft.acct_code, 
             ft.amount, 
             fb.owner_pidm, 
             ft.prog_code      
      from ftrbremb fb , ftcractg ft, ftprexps fx
      where fb.doc_code = 'TR000038'
      --and fb.ftpbport_id = ft.ftpbport_id
      and fx.ftrbremb_id = fb.id
      and ft.ftprexps_id = fx.id;
How can i combine these two statements together so that when the first one is null the second one runs. As a bonus i like to get just the first row as well.
Any help would greatly appreciated. I tried to accomplish with case statement but it just dosent seem to be working for me.
Thanks
This post has been answered by MichaelS on Nov 13 2010
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 11 2010
Added on Nov 13 2010
4 comments
496 views