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

Quellcode-Bibliothek

© Kompilation durch diese Firma

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

Datei: yts806.cob   Sprache: Cobol

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


      * EMBEDDED COBOL (file "YTS772.PCO")


      *Copyright 1996 National Computing Centre Ltd, 
      *and Computer Logic R&D S.A 
      *on behalf of 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                               
      *                                                              
      * YTS772.PCO                                                   
      * WRITTEN BY:  Susan Watters                                   
      * TRANSLATED AUTOMATICALLY FROM EMBEDDED C BY CHRIS SCHANZLE
      *                                                              
      * This routine tests Access to ASSERTIONS view                 
      *                                                              
      *                                                              
      * REFERENCES                                                   
      *   21.2.17  ASSERTIONS view                                   
      *   F#35     Intermediate information schema                   
      *                                                              
      * DATE LAST ALTERED 02.01.96 CTS5 Hand-over Test               
      *                                                              
      * QA Status: Full FC                                           
      *                                                              
      * Revised by DWF 1996-03-13                                    
      *   Added rollback after authid                                
      *   Renamed variables                                          
      *   More output                                                
      *   Removed EXEC SQL from inside printf                        
      *   Rearranged, cleaned up                                     
      *   Fixed syntax error                                         
      *   Changed code to do what the comments said it should do     
      ****************************************************************




           EXEC SQL BEGIN DECLARE SECTION END-EXEC
       01  SQLCODE PIC S9(9) COMP.
       01  SQLSTATE PIC  X(5).
       01  co1 PIC S9(4) DISPLAY SIGN LEADING SEPARATE.
       01  cc PIC  X(128).
       01  cs PIC  X(128).
       01  cn PIC  X(128).
       01  id PIC  X(18).
       01  inid PIC  X(18).
       01  uid PIC  X(18).
       01  uidx PIC  X(18).
             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  i PIC S9(4) DISPLAY SIGN LEADING SEPARATE.
       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 END-EXEC
             MOVE SQLCODE TO SQL-COD
             EXEC SQL ROLLBACK WORK END-EXEC
             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, Embedded COBOL, yts772.pco"
             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 TEST7554 *******************
             MOVE 1 TO flag

             DISPLAY " TEST7554 "
             DISPLAY " Access to ASSERTIONS view"
             DISPLAY "References:"
             DISPLAY " 21.2.17 ASSERTIONS view"
             DISPLAY " F#35 Intermediate information schema"
             DISPLAY " - - - - - - - - - - - - - - - - - - -"

             DISPLAY "The ASSERTIONS view is required in Intermediate
      -    " SQL F#35,"
             DISPLAY "but actual assertions are not required until Full
      -    " SQL F#52."
             DISPLAY "The ASSERTIONS view does not have to contain
      -    " anything for"
             DISPLAY "Intermediate conformance, but if it does, it has
      -    " to be valid"
             DISPLAY "data."

             COMPUTE SQLCODE = -1
             MOVE "xxxxx" TO SQLSTATE

      *initialise variables 

             MOVE "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxx" TO cc

             MOVE "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxx" TO cs

             MOVE "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
      -      "xxxxxxxx" TO cn

             MOVE "xxxxxxxxxxxxxxxxxx" TO id
             MOVE "xxxxxxxxxxxxxxxxxx" TO inid

      *check IS_DEFERRABLE contains no NULL values 

             MOVE 99 TO co1
             DISPLAY "SELECT COUNT (*) INTO :co1"
             DISPLAY "FROM INFORMATION_SCHEMA.ASSERTIONS"
             DISPLAY "WHERE IS_DEFERRABLE IS NULL;"
             EXEC SQL SELECT COUNT (*) INTO :co1
               FROM INFORMATION_SCHEMA.ASSERTIONS
               WHERE IS_DEFERRABLE IS NULL END-EXEC
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY "co1 should be 0; its value is ", co1
             if (co1  NOT =  0) then
               MOVE 0 TO flag
             END-IF

      *check INITIALLY_DEFERRED contains no NULL values 

             MOVE 99 TO co1
             DISPLAY "SELECT COUNT (*) INTO :co1"
             DISPLAY "FROM INFORMATION_SCHEMA.ASSERTIONS"
             DISPLAY "WHERE INITIALLY_DEFERRED IS NULL;"
             EXEC SQL SELECT COUNT (*) INTO :co1
               FROM INFORMATION_SCHEMA.ASSERTIONS
               WHERE INITIALLY_DEFERRED IS NULL END-EXEC
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY "co1 should be 0; its value is ", co1
             if (co1  NOT =  0) then
               MOVE 0 TO flag
             END-IF

      *declare cursor to return all rows of ASSERTIONS view 

             DISPLAY "DECLARE data772 CURSOR FOR"
             DISPLAY "SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA,"
             DISPLAY "CONSTRAINT_NAME, IS_DEFERRABLE,
      -    " INITIALLY_DEFERRED"
             DISPLAY "FROM INFORMATION_SCHEMA.ASSERTIONS;"

             EXEC SQL DECLARE data772 CURSOR FOR
               SELECT CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA,
               CONSTRAINT_NAME, IS_DEFERRABLE, INITIALLY_DEFERRED
               FROM INFORMATION_SCHEMA.ASSERTIONS END-EXEC

             DISPLAY "OPEN data772;"
             EXEC SQL OPEN data772 END-EXEC
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

      *check IS_DEFERRABLE and INITIALLY_DEFERRED 
      *contain acceptable values 

             DISPLAY "For the following fetches, if id is NO, then inid
      -    " must also"
             DISPLAY "be NO."

           .
        P101.
             DISPLAY "FETCH data772 INTO :cc, :cs, :cn, :id, :inid;"
             EXEC SQL FETCH data772 INTO :cc, :cs, :cn, :id, :inid
             END-EXEC
             MOVE SQLCODE TO SQL-COD
             if (SQLCODE  NOT =  0) then
               GO TO P100
             END-IF
           PERFORM CHCKOK
             DISPLAY "id should be YES or NO; its value is ", id
             DISPLAY "inid should be YES or NO; its value is ", inid
             if (id  NOT  =   "NO"  AND  id  NOT  =   "YES"then
               MOVE 0 TO flag
             END-IF
             if (inid  NOT  =   "NO"  AND  inid  NOT  =   "YES"then
               MOVE 0 TO flag
             END-IF
             if (id   =   "NO"  AND  inid  NOT  =   "NO"then
               MOVE 0 TO flag
             END-IF
             GO TO P101

           .
        P100.
             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  " "

             DISPLAY "ROLLBACK WORK;"
             EXEC SQL ROLLBACK WORK END-EXEC
             MOVE SQLCODE TO SQL-COD
           PERFORM CHCKOK
             DISPLAY  " "

             if ( flag  =  1 ) then
               DISPLAY " yts772.pco *** pass *** "
               EXEC SQL INSERT INTO CTS1.TESTREPORT
                 VALUES('7554','pass','PCO'END-EXEC
               MOVE SQLCODE TO SQL-COD
             else
               DISPLAY " yts772.pco *** fail *** "
               EXEC SQL INSERT INTO CTS1.TESTREPORT
                 VALUES('7554','fail','PCO'END-EXEC
               MOVE SQLCODE TO SQL-COD
               COMPUTE errcnt = errcnt + 1
             END-IF

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

             EXEC SQL COMMIT WORK END-EXEC
             MOVE SQLCODE TO SQL-COD
      ******************** END TEST7554 ********************


      **** 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.29 Sekunden  (vorverarbeitet)  ¤





Druckansicht
unsichere Verbindung
Druckansicht
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