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

SQL to see if data exists in the table


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

New User


Joined: 25 Jun 2006
Posts: 14
Location: US

PostPosted: Mon Jan 18, 2010 4:42 pm
Reply with quote

Hi All,

I have a problem in hand.

I need to see whether data exists in DB2 table or not. I need to do the coding in cobol.(embedded)

I don't want to use Count as it will read through the entire table, also I don't want to fetch first record only as it will fetch a record, which i won't use. I just want to see whether data satisfying my where condition exists in the table or not.

i've goggled it and found something like -

IF EXISTS (SQL QUERY)
RETURN 1
ELSE
RETURN 0;


But this piece in not working in mainframe DB2, Is there something like the above exists for mainframe SQL ?

Thank you for your time,
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 18, 2010 4:45 pm
Reply with quote

Quote:
But this piece in not working


as usual the quoted sentence tells absolutely nothing about the issue
an prevents from giving any advice
Back to top
View user's profile Send private message
imain
Warnings : 1

New User


Joined: 25 Jun 2006
Posts: 14
Location: US

PostPosted: Mon Jan 18, 2010 4:50 pm
Reply with quote

enrico-sorichetti wrote:
Quote:
But this piece in not working


as usual the quoted sentence tells absolutely nothing about the issue
an prevents from giving any advice


Sorry buddy,

I meant the given SQL is not getting executed in mainframe environment.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jan 18, 2010 4:53 pm
Reply with quote

Quote:
I meant the given SQL is not getting executed in mainframe environment.

wow, what a detailed, technical response.

in addition to what enrico has said about not providing any information,

why did you
Quote:
i've goggled it and found something like -

and not look in a DB2 manual? (manual buttons at top of page)

had you, you would have discovered that the garbage you pulled out from google is not IBM.

perhaps:

SELECT 1
into :host-numeric-variable
FROM <your table>
WHERE <your conditions>

IF the sqlcode is +100 the data is not there.
an sqlcode of 0 or -811 would indicate that the data is there.

RTFM[/quote]
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 18, 2010 4:53 pm
Reply with quote

Quote:
I meant the given SQL is not getting executed in mainframe environment.


same comment ...
Back to top
View user's profile Send private message
imain
Warnings : 1

New User


Joined: 25 Jun 2006
Posts: 14
Location: US

PostPosted: Mon Jan 18, 2010 5:04 pm
Reply with quote

enrico-sorichetti wrote:
Quote:
I meant the given SQL is not getting executed in mainframe environment.


same comment ...


Ok..Guys Relax,

-------------------------------------------------------------------------------------

WORLD WILL BE A BETTER PLACE, IF YOU TOLD LESS COMPLAINTS RATHER THAN BLAMING
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 18, 2010 5:11 pm
Reply with quote

Quote:
Ok..Guys Relax,


we are relaxed, otherwise we would not be wasting our time to try to help You..
our queries work, the Db2 tables do not need any recovery, out threads are not in a deadlock...
and we have no need to ask a forum.... icon_cool.gif
Back to top
View user's profile Send private message
imain
Warnings : 1

New User


Joined: 25 Jun 2006
Posts: 14
Location: US

PostPosted: Mon Jan 18, 2010 5:17 pm
Reply with quote

enrico-sorichetti wrote:
Quote:
Ok..Guys Relax,


we are relaxed, otherwise we would not be wasting our time to try to help You..
our queries work, the Db2 tables do not need any recovery, out threads are not in a deadlock...
and we have no need to ask a forum.... icon_cool.gif



HELPING! Is this what you call?

hahahah
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 18, 2010 5:28 pm
Reply with quote

I am trying to make You understand how to post sensible question in order to get useful answers.
and is a way to help You, to get useful answers in the shortest time

both my replies pointed out an illogic way of asking
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon Jan 18, 2010 5:35 pm
Reply with quote

a simple forum search for "sql check for row existence"
gave as result
ibmmainframes.com/viewtopic.php?t=38928&highlight=sql+row+existance+existence
or
ibmmainframes.com/viewtopic.php?t=680&highlight=sql+row+existance+existence

try Yourself
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: Tue Jan 19, 2010 6:31 am
Reply with quote

Hello,

Quote:
HELPING! Is this what you call?
Yes, certainly. . .

Demonstrating or pointing out completely non-productive and time-wasting ways to ask for help should help both you as well as others who might not understand how to ask for help without requiring a number of iterations.

If no one told you how bad this approach was, others might read this and believe it is proper to ask for help this way.

And it is not. . .
Back to top
View user's profile Send private message
rockish

Active User


Joined: 05 Jun 2009
Posts: 185
Location: Planet Earth

PostPosted: Fri Jan 22, 2010 12:43 am
Reply with quote

imain wrote:
enrico-sorichetti wrote:
Quote:
Ok..Guys Relax,


we are relaxed, otherwise we would not be wasting our time to try to help You..
our queries work, the Db2 tables do not need any recovery, out threads are not in a deadlock...
and we have no need to ask a forum.... icon_cool.gif



HELPING! Is this what you call?

hahahah


You are right.. Even I dont see it as HELPING.. Probably I would call it as GUIDING.. after all forums are to guide us to perfection icon_smile.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Jan 22, 2010 12:53 am
Reply with quote

Quote:
You are right.. Even I dont see it as HELPING.. Probably I would call it as GUIDING.. after all forums are to guide us to perfection

if You had read the whole topic You would have seen that the TS did not give any useful info on his issue an was only whining about...
Quote:
But this piece in not working
and
Quote:
I meant the given SQL is not getting executed in mainframe environment.


just think about...
if You were a manager would You accept Your employees wasting "billing" consultants time with badly posed questions
meditate about it, but most probably not

here an even wore aspect emerges,
anybody can waste somebody else time because they do not pay for it..
and furthermore we get <******>remarks when we try to correct the
approach!
looks like this time You just did not behave according to Your signature icon_cool.gif
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 Store the data for fixed length COBOL Programming 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Data set Rec-Cnt and Byte-Cnt Testing & Performance 2
No new posts SCOPE PENDING option -check data DB2 2
Search our Forums:

Back to Top