|
Good idea. If I declare the cursor as "optimize for 1 record" then I may even see this perform in a decent manner. Hopefully, if I select only key fields DB2/SMP will see that this can be accomplished with index covering and I will never even hit the physical. -Walden -----Original Message----- From: Vern Hamberg <hambergv@goldengate.net> To: MIDRANGE-L@midrange.com <MIDRANGE-L@midrange.com> Cc: walden@techsoftinc.com <walden@techsoftinc.com> Date: Tuesday, November 18, 1997 5:33 PM Subject: Re: SQL Existence Check >Walden > >At 12:23 PM 11/14/97 -0500, you wrote: >>I would like to check for the existence of a record in a file using SQL. >>There could be 0, 1 or more than 1 records that match the selection >>criteria, I only care if records exist, not how many. >> >>I know that SQL has the EXISTS predicate, but I cannot use it by itself, it >>must be in the where clause of a statement. I realize that I could do a >>select count(*) where.... but this would require DB2/400 to read all the >>matching records in order to count them. In my case as soon as DB2 finds 1 >>record it can stop looking. > >Is this embedded SQL? If so, FETCH and check the return code. Doesn't -100 >mean no more records? > >If not embedded, I'll have to think about it some more. > >HTH >Vernon Hamberg >Systems Software Programmer >Old Republic National Title Insurance Company >400 Second Avenue South >Minneapolis, MN 55401 >(612) 371-1111 x480 > +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to "MIDRANGE-L@midrange.com". | To unsubscribe from this list send email to MAJORDOMO@midrange.com | and specify 'unsubscribe MIDRANGE-L' in the body of your message. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.