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
 

 

SQL to see if data exists in the table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: SQL to see if data exists in the table
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jan 18, 2010 4:45 pm    Post subject: Reply to: SQL to see if data exists in the table
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    Post subject: Re: Reply to: SQL to see if data exists in the table
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    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jan 18, 2010 4:53 pm    Post subject: Reply to: SQL to see if data exists in the table
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    Post subject: Re: Reply to: SQL to see if data exists in the table
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jan 18, 2010 5:11 pm    Post subject: Reply to: SQL to see if data exists in the table
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    Post subject: Re: Reply to: SQL to see if data exists in the table
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jan 18, 2010 5:28 pm    Post subject: Reply to: SQL to see if data exists in the table
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Mon Jan 18, 2010 5:35 pm    Post subject: Reply to: SQL to see if data exists in the table
Reply with quote

a simple forum search for "sql check for row existence"
gave as result
http://ibmmainframes.com/viewtopic.php?t=38928&highlight=sql+row+existance+existence
or
http://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

Site Director


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

PostPosted: Tue Jan 19, 2010 6:31 am    Post subject:
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    Post subject: Re: Reply to: SQL to see if data exists in the table
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Fri Jan 22, 2010 12:53 am    Post subject: Reply to: SQL to see if data exists in the table
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    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 Is the 'prompt' data for the DSLIST p... Willy Jensen TSO/ISPF 1 Tue Dec 06, 2016 4:38 am
No new posts How to move a long alphanumeric data ... lind sh COBOL Programming 5 Mon Dec 05, 2016 7:51 pm
No new posts ODPP(Optim Data privacy Provider) Iss... Rama kishore IBM Tools 1 Mon Nov 07, 2016 5:46 pm
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm


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