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

SELECT without a into clause


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Fri Oct 31, 2008 7:29 pm
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
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

Moderator Emeritus


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

PostPosted: Mon Nov 03, 2008 7:56 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts To search DB2 table based on Conditio... DB2 1
No new posts Select a DB2 value in a specific deci... DB2 4
Search our Forums:

Back to Top