IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 - IF EXISTS statement


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
marisalondon

New User


Joined: 21 Aug 2009
Posts: 10
Location: London

PostPosted: Wed Nov 11, 2009 2:00 pm
Reply with quote

Hi

I am trying to run a SQL sentence using a batch job (JCL is successful). The SQL sentence is introduced in a file.

Purpose to be able to
SET CURRENT SQLID = ‘XXX’
CREATE SYNONYM BBB for XXX.BBB

The problem is that if the synonym exist, then it fails (RC=8). I tried to DROP, but again errors out if it doesn’t exist.

At this point, we tried to use IF EXISTS.

We are trying with:

IF NOT EXISTS (SELECT * FROM SYSIBM.SYSSYNONYM WHERE NAME = BBB) THEN CREATE SYNONYM ...

The errors SQLCODE -104 (Illegal exists)

Any suguestions?

Thanks,
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Wed Nov 11, 2009 6:09 pm
Reply with quote

Hi Marisalondon,

IF statements are used in stored procedures, not in a query processor.

Sushanth
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Thu Nov 12, 2009 4:10 am
Reply with quote

Hi marisalondon,

Can you post your drop statement. Did you commit after drop?.


Thanks
Sai
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
No new posts process statement for SUPREC, CMPCOLM... TSO/ISPF 4
No new posts SYNCSORT/ICETOOL JOINKEYS SORT Statem... DFSORT/ICETOOL 13
No new posts DFDSS COPY using Filter REFDT statement JCL & VSAM 2
Search our Forums:

Back to Top