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
 

 

SELECT without a into clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
santsark

New User


Joined: 08 Aug 2008
Posts: 9
Location: Kolkata

PostPosted: Fri Oct 31, 2008 11:18 am    Post subject: SELECT without a into clause
Reply with quote

I'm trying to verify if a value is present in the table before inserting. So i want to write a select statement but do not use any host variable. Is it possible,

like select
from table
where Column_A = :WS-A

I will then evaluate the sql code and determine if I need to insert or not.
I can not change table constraints like unique keys and all, so this is the only solution.

Please let me know if i can write a select statement without the into clause. I'm getting pre-compiler error now.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Oct 31, 2008 7:29 pm    Post subject:
Reply with quote

Hello,

You might use an IF EXISTS and use a COUNT in the select. . .
Back to top
View user's profile Send private message
i_suman

New User


Joined: 01 Mar 2005
Posts: 20

PostPosted: Mon Nov 03, 2008 7:28 am    Post subject: Reply to: SELECT without a into clause
Reply with quote

I think you can try this too

SELECT '1'
FROM tablename
WHERE column1 = :ws-var
FETCH FIRST 1 ROW ONLY

Anyone, please correct me if I am wrong.

Thanks
Suma
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon Nov 03, 2008 7:56 am    Post subject:
Reply with quote

Hello,

Quote:
I think you can try this too
Anything can be tried. . .

Did you test this before posting? What was the result?

If you did not test this, please do so now and post back the outcome. The test needs to be within a cobol program, not spufi.

It is far too easy to test something like this before posting and then post the result as well as the suggested syntax. . .
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 Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm
No new posts Query to select Null row on priority RahulG31 DB2 24 Thu Jan 21, 2016 5:45 pm
No new posts Can I use sort to select sample recor... Steve Ironmonger DFSORT/ICETOOL 3 Tue Nov 10, 2015 10:02 pm


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