Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 - IF EXISTS statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 - IF EXISTS statement
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: 1013
Location: India

PostPosted: Wed Nov 11, 2009 6:09 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts VALIDATE NULL VALUE IN DB2 CASE STATE... useit DB2 5 Thu Feb 09, 2017 4:34 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am
No new posts Converting NULL column into NOT NULL ... Raghu navaikulam DB2 5 Sat Aug 06, 2016 3:45 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us