Version 4.2.6 for Mainframes
 —  Database Management System Interfaces  —

Natural System Commands for the Natural SQL Gateway

The following system commands are available:


LISTSQL Command

LISTSQL  [object-name]

The LISTSQL command lists the Natural statements in the source code of a programming object that are associated with a relational database access, and the corresponding SQL statements into which they have been translated.

LISTSQL is issued from the Natural NEXT prompt.

Thus, before executing a Natural program which accesses an SQL table, you can view the generated SQL code by using the command LISTSQL.

If a valid object name is specified, the object to be displayed must be cataloged or stowed in the library to which you are currently logged on.

If no object name is specified, LISTSQL refers to the object currently in the Natural source area.

In any case, LISTSQL needs a cataloged or stowed object to perform is functionality.

The generated SQL statements contained in the specified object are listed one per page.

Sample LISTSQL Screen

09:44:09               ***** NATURAL TOOLS FOR SQL *****            2009-09-11
 Member NSBDSEL                   - LISTSQL -                  Library SYSDB2  
                                                                               
 Natural statement  at line 0150                                 Stmt   1 / 1  
                                                                               
   SELECT *                                                                    
       INTO VIEW NSB-DEMO                                                      
       FROM NSB-DEMO                                                           
                                                                               
 Generated SQL statement   Mode : dynamic  DBRM :                Line   1 / 3  
                                                                               
   SELECT  PERS_ID, NAME, ADDRESS, DATEOFBIRTH, SALARY                         
   FROM    NSB.DEMO                                                            
   FOR FETCH ONLY                                                              
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
Command ===>                                        Queryno for EXPLAIN 1____  
                                                                               
Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
            Error Exit  Expl        Parms  -     +          Prev  Next  Canc

Within the listed results, you can go from one listed SQL statement to another by pressing PF10 (Prev) or PF11 (Next). If a single SQL statement does not fit on the screen, you can scroll backwards or forwards by pressing PF7 or PF8, respectively.

If an error occurs, PF2 (Error), which executes the SQLERR system command (described in SQLERR Command), can be used to provide information on SQL errors.

With PF6 (Parms), a further screen is displayed which lists all parameters from the SQLDA for the currently displayed SQL statement:

 09:46:47               ***** NATURAL TOOLS FOR SQL *****            2009-09-11
 Member NSBDSEL                     LISTSQL                    Library SYSDB2  
                                                                               
         Mode : dynamic   DBRM :           Contoken :                          
                    (3rd/pre)                                                  
         static parms : (1st)                                                  
                        (2nd)                                                  
         SQLDA                                                                 
                                   DBID : 255  FNR : 102  CMD : S1 0150 08     
     Nr  Type     Length     CCSID                                             
      1. CHAR             10       8001 0000 000A 01C4 0000 0000 1E00 0000     
      2. CHAR             20       8002 0000 0014 01C4 0000 0000 0800 0000     
      3. CHAR            100       8003 0000 0064 01C4 0000 0000 0800 0000     
      4. CHAR             10       8004 0000 000A 01C4 0000 0000 0800 0000     
      5. DECIMAL         9.2       8005 4000 0902 01E5 0000 0000 0800 0000     
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
                                                                               
Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
                  Exit                     -     +                      Canc   

Top of page

SQLERR Command

The SQLERR system command is used to obtain diagnostic information on an SQL error.

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

The SQLERR system 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

                   *** SQLERR Diagnostic Information ***                      
 ---------------------- Natural SQL Interface Codes ------------------------- 
 Return Code: 3700    Reason Code: 0                 ZZN01   SQL code: -4017  
 --------------------------------- SQLCA ------------------------------------ 
                                                                              
 SQLERRD (Additional Information)                                             
                                                                              
         Number of Rows Processed                           :           0     
                                                                              
                                                                              
                                                                              
 SQLWARN (Warning Flags)                                                      
         Data truncated                                     :                 
                                                                              
         No. of columns greater than No. of host variables  :                 
 CNX Error Message :                                                          
4017(E): SERVER ERROR: ODBC:(HY000) NATIVE:(0) : Ambiguous table reference: (D
EMO) ? PERS_ID , NAME , ADDRESS , DATEOFBIRTH , SALARY FROM << Syntax Error >>
  NSB.DEMO ?.                                                                 
                                                                              
                                                                              









                                                                               
                                                                               
Enter-PF1---PF2---PF3---PF4---PF5---PF6---PF7---PF8---PF9---PF10--PF11--PF12---
            Error Exit  Expl        Parms  -     +          Prev  Next  Canc

Top of page