SQLERR

SQLERR

Note:
This command is only available with Natural for DB2.

The SQLERR command is used to obtain diagnostic information about the most recent SQL error.

When an SQL error occurs, Natural issues an appropriate error message. When you enter the SQLERR command, the following information on the most recent SQL error is displayed:

  • the Natural error message number;

  • the corresponding reason code (if applicable);

  • the variables SQLSTATE and SQLCODE returned by DB2;

  • the corresponding error message.

The SQLERR command can be issued either from the Natural NEXT prompt or from within a Natural program (by using the FETCH statement).

Sample SQLERR Diagnostic Information Screen (Natural for DB2)

                ***** SQLERR Diagnostic Information *****                   
---------------------- NATURAL SQL Interface Codes -------------------------
Return Code: 3700    Reason Code: 0      SQLSTATE : 52003    SQLCODE: -206 
--------------------------------- SQLCA-------------------------------------
SQLERRP (DB2 Sub routine where error occurred)             :  DSNXOGP       
SQLERRD (DB2 Internal State)                                                
        RDS Return Code                                    :         700    
        DBSS Return Code                                   :           0    
        Number of Rows Processed                           :           0    
        Estimated Cost                                     :          11.2  
        Syntax error on PREPARE or EXECUTE IMMEDIATE       :           0    
        Buffer Manager ERROR Code                          :           0    
SQLWARN (Warning Flags)                                                     
        Data truncated                                                      
        Null Values ignored (AVG,SUM,MAX,MIN)              :                
        No. of columns greater than no. of host variables  :                
        UPDATE/DELETE without WHERE clause                 :                
        SQL Statement not valid in DB2                     :                
         Adjustment to DATE/TIMESTAMP Variable made         :               
DB2 Error Message :                                                    
DSNT4081 SQLCODE = -206, ERROR: THE OBJECT TABLE OR VIEW OF THE INSERT,
              DELETE, OR UPDATE STATEMENT IS ALSO IDENTIFIED IN A FROM CLAUSE