Re: A Q about Pro*C

From: Craig L Hollister <Craig.Hollister_at_DaytonOH.NCR.COM>
Date: 1995/07/07
Message-ID: <DBD6B4.944_at_intruder.daytonoh.attgis.com>#1/1


Stewart McKenna, 7/7/95, wrote:

>"Wang, Wei" <wangww_at_ucsub.colorado.edu> wrote:
>>
>> EXEC SQL SELECT COUNT(*) INTO :i
>> FROM :table_name;
 

>Be careful with column functions like Count(*). Make sure that you
>handle the sqlcode if no rows exist, or qualify ! I forget how we're
>handling it here for Oracle, but in DB2 you had to use indicator
>variables to handle this situation. [...]

A query of the form "EXEC SQL SELECT COUNT(*) INTO :i FROM t" (barring an error) will return exactly one row. There is no need to check the SQLCODE for a no data found condition.

Furthermore, the value returned to the host variable by such a query (barring an error) will never be null. Adding an indicator variable will only confirm the certain. Received on Fri Jul 07 1995 - 00:00:00 CEST

Original text of this message