products/sources/formale sprachen/Cobol/Test-Suite/SQL M image not shown  

Quellcode-Bibliothek

© Kompilation durch diese Firma

[Weder Korrektheit noch Funktionsfähigkeit der Software werden zugesichert.]

Datei: xts758.cob   Sprache: Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID.  XTS758.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER.  xyz.
       OBJECT-COMPUTER.  xyz.
       DATA DIVISION.
       WORKING-STORAGE SECTION.


      * Standard COBOL (file "XTS758.SCO") calling SQL
      * procedures in file "XTS758.MCO".


      *Copyright 1995 National Computing Centre Limited               
      *and Computer Logic R&D S.A                                     
      *on behalf of the CTS5 SQL2 Project.                            
      *All rights reserved.                                          
      *The CTS5 SQL2 Project is sponsored by the European Community. 
      *                                                             
      *The National Computing Centre Limited and Computer Logic R&D  
      *have given permission to NIST to distribute this program      
      *over the World Wide Web in order to promote SQL standards.    
      *DISCLAIMER:                                                   
      *This program was reviewed by employees of NIST for            
      *conformance to the SQL standards.                             
      *NIST assumes no responsibility for any party's use of         
      *this program.                                                 


      ****************************************************************
      *                                                              
      *                 COMMENT SECTION                              
      *                                                              
      * SQL VALIDATION TEST SUITE V6.0                               
      *                                                              
      * XTS758.SCO                                                   
      * WRITTEN BY: Nickos Backalidis                                
      * TRANSLATED AUTOMATICALLY FROM EMBEDDED COBOL BY CHRIS SCHANZLE
      *                                                              
      * Scrolled cursor FETCH ABSOLUTE non-literal after last row    
      *                                                              
      * REFERENCES                                                   
      *   13.1    -- <Declare cursor>                                
      *   13.3    -- <Fetch statement>                               
      *   13.3 GR.5b                                                 
      *   F#24    -- Keyword relaxations                             
      *   F#43    -- Scrolled cursors                                
      *                                                              
      * DATE LAST ALTERED  18/12/95 CTS5 Hand-over Test              
      *                                                              
      * Cleanups and fixes by V. Kogakis 15/12/95                    
      *        Print timestamp                                       
      *        Include Files                                         
      *        Define NOSUBCLASS/CHCKOK at test beginning            
      *                                                              
      * QA STATUS : QA CHECK                                         
      *                                                              
      * Revised by DWF 1996-02-20                                    
      *   Removed status checks after cursor definition              
      *   Shortened variable names to 6 chars                        
      *   Removed field width from printf                            
      *   Fixed string lengths                                       
      *   Fixed wrong SQLCODE expected                               
      ****************************************************************



      * EXEC SQL BEGIN DECLARE SECTION END-EXEC
       01  SQLCODE PIC S9(9) COMP.
       01  SQLSTATE PIC  X(5).
       01  uid PIC  X(18).
       01  uidx PIC  X(18).
       01  num1 PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
       01  chr1 PIC  X(10).
       01  rowptr PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
      *  EXEC SQL END DECLARE SECTION END-EXEC
       01  norm1 PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
       01  norm2 PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
       01  ALPNUM-TABLE VALUE IS
               "01234ABCDEFGH56789IJKLMNOPQRSTUVWXYZ".
           05  ALPNUM PIC X OCCURS 36 TIMES.
       01  NORMSQ.
           05  NORMSQX PIC X OCCURS 5 TIMES.
       01  errcnt PIC S9(9) DISPLAY SIGN LEADING SEPARATE.
      *date_time declaration 
       01  TO-DAY PIC 9(6).
       01  THE-TIME PIC 9(8).
       01  flag PIC S9(9) DISPLAY SIGN LEADING SEPARATE.

       01  SQL-COD PIC S9(9) DISPLAY SIGN LEADING SEPARATE.

       PROCEDURE DIVISION.
       P0.

             MOVE "CTS1 " TO uid
             CALL "AUTHID" USING uid
             MOVE "not logged in, not" TO uidx
      *  EXEC SQL SELECT USER INTO :uidx FROM CTS1.ECCO;
             CALL "SUB1" USING SQLCODE SQLSTATE uidx
             MOVE SQLCODE TO SQL-COD
      *  EXEC SQL ROLLBACK WORK;
             CALL "SUB2" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
             if (uid  NOT  =   uidx) then
               DISPLAY "ERROR: User ", uid, " expected. User ", uidx, "
      -    " connected"
            STOP RUN
             END-IF
             MOVE 0 TO errcnt

             DISPLAY "SQL Test Suite, V6.0, Module COBOL, xts758.sco"
             DISPLAY
           "59-byte ID"
             DISPLAY "TEd Version #"
      *date_time print 
           ACCEPT TO-DAY FROM DATE
           ACCEPT THE-TIME FROM TIME
           DISPLAY "Date run YYMMDD: " TO-DAY " at hhmmssff: " THE-TIME

      ******************** BEGIN TEST7058 *******************
             MOVE 1 TO flag
             DISPLAY " TEST7058"
             DISPLAY " Scrolled cursor FETCH ABSOLUTE non-literal,
      -    " after last row"
             DISPLAY " References"
             DISPLAY " 13.1 -- "
             DISPLAY " 13.3 -- "
             DISPLAY " 13.3 GR.5b "
             DISPLAY " F#24 -- Keyword relaxations"
             DISPLAY " F#43 -- Scrolled cursors "
             DISPLAY " - - - - - - - - - - - - - - - - - - -"

      *Initialise error reporting variables 
             COMPUTE SQLCODE = -1
             MOVE "xxxxx" TO SQLSTATE

      *create a table under the current schema 
             DISPLAY "CREATE TABLE TAB758"
             DISPLAY "(COL1 NUMERIC(5) PRIMARY KEY UNIQUE,"
             DISPLAY " COL2 CHAR(10));"
      *  EXEC SQL CREATE TABLE TAB758
      *    (COL1 NUMERIC(5) PRIMARY KEY UNIQUE,
      *    COL2 CHAR(10));
             CALL "SUB3" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "COMMIT WORK;"
      *  EXEC SQL COMMIT WORK;
             CALL "SUB4" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

      *now insert five rows in the table 
             DISPLAY "INSERT INTO TAB758 VALUES(101,'NICKOS');"
      *  EXEC SQL INSERT INTO TAB758 VALUES(101,'NICKOS');
             CALL "SUB5" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "INSERT INTO TAB758 VALUES(103,'LUNA');"
      *  EXEC SQL INSERT INTO TAB758 VALUES(103,'LUNA');
             CALL "SUB6" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "INSERT INTO TAB758 VALUES(105,'LOLA');"
      *  EXEC SQL INSERT INTO TAB758 VALUES(105,'LOLA');
             CALL "SUB7" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "INSERT INTO TAB758 VALUES(102,'LILIAN');"
      *  EXEC SQL INSERT INTO TAB758 VALUES(102,'LILIAN');
             CALL "SUB8" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "INSERT INTO TAB758 VALUES(104,'MARION');"
      *  EXEC SQL INSERT INTO TAB758 VALUES(104,'MARION');
             CALL "SUB9" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "COMMIT WORK;"
      *  EXEC SQL COMMIT WORK;
             CALL "SUB10" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "DECLARE SCRCURS SCROLL CURSOR FOR SELECT
      -    " COL1,COL2"
             DISPLAY "FROM TAB758"
             DISPLAY "ORDER BY COL1;"
      *  EXEC SQL DECLARE SCRCURS SCROLL CURSOR FOR SELECT COL1,COL2
      *    FROM TAB758
      *    ORDER BY COL1 END-EXEC

             DISPLAY "OPEN SCRCURS;"
      *  EXEC SQL OPEN SCRCURS;
             CALL "SUB11" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

      *initialise host variables 
             MOVE 0 TO num1
             MOVE "xxxxxxxxxx" TO chr1
             MOVE 5 TO rowptr

      *now fetch the last row of the cursor row 
             DISPLAY "FETCH ABSOLUTE :rowptr FROM SCRCURS INTO
      -    " :num1,:chr1;"
      *  EXEC SQL FETCH ABSOLUTE :rowptr FROM SCRCURS INTO
      *  :num1,:chr1;
             CALL "SUB12" USING SQLCODE SQLSTATE rowptr num1 chr1
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY "COL1 should be 105; its value is ", num1
             DISPLAY "COL2 should be LOLA; its value is ", chr1
             if (chr1  NOT  =   "LOLA"  OR  num1  NOT =  105) then
               MOVE 0 TO flag
             END-IF
             DISPLAY  " "

      *initialise host variables 
             MOVE 0 TO num1
             MOVE "xxxxxxxxxx" TO chr1
             DISPLAY "Non literal is incremented by 1"
             COMPUTE rowptr = rowptr + 1

             DISPLAY "FETCH ABSOLUTE :rowptr FROM SCRCURS INTO
      -    " :num1,:chr1;"
      *  EXEC SQL FETCH ABSOLUTE :rowptr FROM SCRCURS INTO
      *  :num1,:chr1;
             CALL "SUB13" USING SQLCODE SQLSTATE rowptr num1 chr1
             MOVE SQLCODE TO SQL-COD
      *Check that an exception condition no data is raised     
      *indicated in the value of SQLSTATE which should be 02000
             DISPLAY "SQLCODE should be 100; its value is ", SQL-COD
             DISPLAY "SQLSTATE should be 02000; its value is ", SQLSTATE
           PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS
             if (SQLCODE  NOT =  100  OR  NORMSQ  NOT  =   "02000"then
               MOVE 0 TO flag
             END-IF
             if (NORMSQ   =   "02000"  AND  NORMSQ  NOT  =   SQLSTATE)
             then
               DISPLAY "Valid implementation-defined SQLSTATE accepted."
             END-IF
             DISPLAY  " "

      *now decrement the host variable by 1 
      *this should return the fifth row of the table 

      *initialise host variables 
             MOVE 0 TO num1
             MOVE "xxxxxxxxxx" TO chr1
             DISPLAY "Non literal host variable is decremented by 1"
             COMPUTE rowptr = rowptr - 1

             DISPLAY "FETCH ABSOLUTE :rowptr FROM SCRCURS INTO
      -    " :num1,:chr1;"
      *  EXEC SQL FETCH ABSOLUTE :rowptr FROM SCRCURS INTO
      *  :num1,:chr1;
             CALL "SUB14" USING SQLCODE SQLSTATE rowptr num1 chr1
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY "COL1 should be 105; its value is ", num1
             DISPLAY "COL2 should be LOLA; its value is ", chr1
             if (chr1  NOT  =   "LOLA"  OR  num1  NOT =  105) then
               MOVE 0 TO flag
             END-IF
             DISPLAY  " "

             DISPLAY "CLOSE SCRCURS;"
      *  EXEC SQL CLOSE SCRCURS;
             CALL "SUB15" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "ROLLBACK WORK;"
      *  EXEC SQL ROLLBACK WORK;
             CALL "SUB16" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

      *restore database in its original state 
             DISPLAY "DROP TABLE TAB758 CASCADE;"
      *  EXEC SQL DROP TABLE TAB758 CASCADE;
             CALL "SUB17" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             DISPLAY "COMMIT WORK;"
      *  EXEC SQL COMMIT WORK;
             CALL "SUB18" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

      *record results 
             if ( flag  =  1 ) then
               DISPLAY " xts758.mco *** pass *** "
      *    EXEC SQL INSERT INTO CTS1.TESTREPORT
      *      VALUES('7058','pass','MCO');
               CALL "SUB19" USING SQLCODE SQLSTATE
               MOVE SQLCODE TO SQL-COD
             else
               DISPLAY " xts758.mco *** fail *** "
      *    EXEC SQL INSERT INTO CTS1.TESTREPORT
      *      VALUES('7058','fail','MCO');
               CALL "SUB20" USING SQLCODE SQLSTATE
               MOVE SQLCODE TO SQL-COD
               COMPUTE errcnt = errcnt + 1
             END-IF

             DISPLAY "========================================"

      *  EXEC SQL COMMIT WORK;
             CALL "SUB21" USING SQLCODE SQLSTATE
             MOVE SQLCODE TO SQL-COD
      ******************** END TEST7058 ********************

      **** TESTER MAY CHOOSE TO INSERT CODE FOR errcnt > 0
           STOP RUN.

      *    ****  Procedures for PERFORM statements

      *Test SQLCODE and SQLSTATE for normal completion. 
       CHCKOK.
             DISPLAY "SQLCODE should be 0; its value is ", SQL-COD
             DISPLAY "SQLSTATE should be 00000; its value is ", SQLSTATE
             PERFORM NOSUBCLASS THRU EXIT-NOSUBCLASS
             if (SQLCODE NOT =  0  OR   NORMSQ NOT = "00000"then
               MOVE 0 TO flag
             END-IF
             if (NORMSQ = "00000"  AND  NORMSQ NOT = SQLSTATE)
             then
               DISPLAY "Valid implementation-defined SQLSTATE accepted."
             END-IF
             .

       NOSUBCLASS.

      *This routine replaces valid implementation-defined       
      *subclasses with 000.  This replacement equates valid     
      *implementation-defined subclasses with the 000 value     
      *expected by the test case; otherwise the test will fail. 
      *After calling NOSUBCLASS, NORMSQ will be tested          
      *                          SQLSTATE will be printed.      

           MOVE SQLSTATE TO NORMSQ

           MOVE 3 TO norm1
      *subclass begins in position 3 of char array NORMSQ 
      *valid subclass begins with 5-9, I-Z, end of ALPNUM table 
           PERFORM VARYING norm2 FROM 14 BY 1 UNTIL norm2 > 36
           if (NORMSQX(norm1)  =  ALPNUM(norm2)) then
             MOVE "0" TO NORMSQX(norm1)
           END-IF
           END-PERFORM
           
      *Quit if NORMSQ is unchanged.  Subclass is not impl.-def. 
      *Changed NORMSQ means implementation-defined subclass,    
      *so proceed to zero it out, if valid (0-9,A-Z)            
           if (NORMSQ   =   SQLSTATE) then
             GO TO EXIT-NOSUBCLASS
           END-IF

           MOVE 4 TO norm1
      *examining position 4 of char array NORMSQ 
      *valid characters are 0-9, A-Z 
           PERFORM VARYING norm2 FROM 1 BY 1 UNTIL norm2 > 36
           if (NORMSQX(norm1)  =  ALPNUM(norm2)) then
             MOVE "0" TO NORMSQX(norm1)
           END-IF
           END-PERFORM
          
           MOVE 5 TO norm1
      *valid characters are 0-9, A-Z 
      *examining position 5 of char array NORMSQ 
           PERFORM VARYING norm2 FROM 1 BY 1 UNTIL norm2 > 36
           if (NORMSQX(norm1)  =  ALPNUM(norm2)) then
             MOVE "0" TO NORMSQX(norm1)
           END-IF
           END-PERFORM
   
      *implementation-defined subclasses are allowed for warnings 
      *(class = 01).  These equate to successful completion 
      *SQLSTATE values of 00000. 
      *Reference SQL-92 4.28 SQL-transactions, paragraph 2 

           if (NORMSQX(1)  =  "0"  AND  NORMSQX(2)  =  "1"then
             MOVE "0" TO NORMSQX(2)
           END-IF
           .

       EXIT-NOSUBCLASS.
           EXIT.

¤ Dauer der Verarbeitung: 0.25 Sekunden  (vorverarbeitet)  ¤





Download des
Quellennavigators
Download des
sprechenden Kalenders

in der Quellcodebibliothek suchen




Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.


Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.


Bot Zugriff