Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
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

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us