COUNT(*) gives SQL Code 100 despite finding data



IBM's flagship relational database management system

COUNT(*) gives SQL Code 100 despite finding data

Postby RushTheDev » Fri Jun 16, 2023 6:47 pm

Hello, I have a query about the COUNT(*) function.

The script I run is to count all the rows of the table.

SELECT COUNT(*) FROM TABLE_NAME_HERE;
 


This works fine, however, it returns an SQL Code of 100.

The result is 303 (the correct amount of rows on the table). It is only after the commit which is enabled on the SPUFI settings does it return an SQL Code of 0.

---------+---------+---------+---------+---------+---------+---------+---------+
303
DSNE610I NUMBER OF ROWS DISPLAYED IS 1
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 100
---------+---------+---------+---------+---------+---------+---------+---------+
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE617I COMMIT PERFORMED, SQLCODE IS 0
DSNE616I STATEMENT EXECUTION WAS SUCCESSFUL, SQLCODE IS 0
---------+---------+---------+---------+---------+---------+---------+---------+
DSNE601I SQL STATEMENTS ASSUMED TO BE BETWEEN COLUMNS 1 AND 72
DSNE620I NUMBER OF SQL STATEMENTS PROCESSED IS 1
DSNE621I NUMBER OF INPUT RECORDS READ IS 1
DSNE622I NUMBER OF OUTPUT RECORDS WRITTEN IS 17
******************************** Bottom of Data ********************************

Does anyone know why this is? When this runs in a COBOL program it always returns +100 which is NOT-FOUND.
RushTheDev
 
Posts: 1
Joined: Fri Jun 16, 2023 6:39 pm
Has thanked: 0 time
Been thanked: 0 time

Re: COUNT(*) gives SQL Code 100 despite finding data

Postby engh » Thu Jun 22, 2023 5:35 pm

Hi

The official IBM documentation here :
https://www.ibm.com/docs/en/db2-for-zos/11?topic=codes-100
says

When a SELECT statement is executed using SPUFI, this SQLCODE indicates normal completion.
engh
 
Posts: 9
Joined: Fri Jul 08, 2022 7:29 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post