IBM Support

SQL0501N when a SELECT statement is issued from a DB2 Client connecting to DB2 z/OS database

Troubleshooting


Problem

How to resolve SQL0501N error when a SELECT statement is issued from a DB2 Client command line or Control Center connecting to a DB2 database running on z/OS?

Symptom

SQL statement issued from DB2 client command line

db2 "select count(*) from sysibm.sysvolumes";


    Result:

    SQL0965W There is no message text corresponding to SQL warning "98" in the message file on this workstation. The warning was returned from module "DSNHTOKR" with original tokens "". SQLSTATE=01568

    SQL0501N The cursor specified in a FETCH statement or CLOSE statement is not open or a cursor variable in a cursor scalar function reference is not open. SQLSTATE=24501


Snippet of db2trace.fmt from DB2 Client showing -501 error:

    7224 data DB2 UDB command line process clp_fetch_rows fnc
    (3.3.41.55.0.111)
    pid 2568 tid 964 cpid -1 node 0 sec 86 nsec 990584299 probe 111
    bytes 144
    Data1 (PD_DB2_TYPE_SQLCA,136) SQLCA:
    sqlcaid : SQLCA sqlcabc: 136 sqlcode: -501 sqlerrml: 0
    sqlerrmc:
    sqlerrp : SQLACALL
    sqlerrd : (1) 0x8000008C (2) 0x0000008C (3) 0x00000000
    (4) 0x00000000 (5) 0x00000000 (6) 0x00000000
    sqlwarn : (1) (2) (3) (4) (5) (6)
    (7) (8) (9) (10) (11)
    sqlstate: 24501

[{"Product":{"code":"SSEPDU","label":"Db2 Connect"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Not Applicable","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;9.1;10.1","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
30 April 2025

UID

swg21515847