products/sources/formale Sprachen/Cobol/verschiedene-Autoren/IBM/     Datei vom 22.6.2008 mit Größe 8 kB image not shown  

SSL P11.cob   Interaktion und
PortierbarkeitCobol

 
      ******************************************************************
      ** Licensed Materials - Property of IBM
      **
      ** Governed under the terms of the International
      ** License Agreement for Non-Warranted Sample Code.
      **
      ** (C) COPYRIGHT International Business Machines Corp. 1995 - 2002
      ** All Rights Reserved.
      **
      ** US Government Users Restricted Rights - Use, duplication or
      ** disclosure restricted by GSA ADP Schedule Contract with IBM Cor
      ******************************************************************
      **
      ** SOURCE FILE NAME: tabsql.sqb
      **
      ** SAMPLE: Demonstrates common table expressions using SQL
      **
      **         This program demonstrates how to use common table
      **         expressions using the following advanced SQL statements
      **
      **   WITH
      **   PAYLEVEL AS (SELECT EMPNO, YEAR(HIREDATE) AS HIREYEAR, EDLEVE
      **      SALARY+BONUS+COMM AS TOTAL_PAY FROM EMPLOYEE
      **      WHERE EDLEVEL > 16),
      **   PAYBYED (EDUC_LEVEL, YEAR_OF_HIRE, AVG_TOTAL_PAY) AS
      **      (SELECT EDLEVEL, HIREYEAR, AVG(TOTAL_PAY) FROM PAYLEVEL
      **      GROUP BY EDLEVEL, HIREYEAR)
      **   SELECT EMPNO, EDLEVEL, YEAR_OF_HIRE, TOTAL_PAY, AVG_TOTAL_PAY
      **      FROM PAYLEVEL, PAYBYED
      **      WHERE EDLEVEL=EDUC_LEVEL
      **         AND HIREYEAR = YEAR_OF_HIRE
      **         AND TOTAL_PAY < AVG_TOTAL_PAY;
      **
      **            The second example is described in the "Nested Table
      **            Expressions" section of "Using SQL - Advanced".
      **   SELECT EDLEVEL, HIREYEAR, AVG(TOTAL_PAY)
      **      FROM (
      **         SELECT EMPNO, YEAR(HIREDATE) AS HIREYEAR, EDLEVEL,
      **            SALARY+BONUS+COMM AS TOTAL_PAY FROM EMPLOYEE
      **            WHERE EDLEVEL > 16
      **         ) AS PAY_LEVEL
      **      GROUP BY EDLEVEL, HIREYEAR
      **
      ** SQL STATEMENTS USED:
      **         BEGIN DECLARE SECTION
      **         END DECLARE SECTION
      **         CONNECT
      **         DECLARE
      **         FETCH
      **         OPEN
      **
      ** OUTPUT FILE: tabsql.out (available in the online documentation)
      ******************************************************************
      **
      ** For more information on the sample programs, see the README fil
      **
      ** For information on developing COBOL applications, see the
      ** Application Development Guide.
      **
      ** For information on using SQL statements, see the SQL Reference.
      **
      ** For the latest information on programming, compiling, and runni

      **     http://www.software.ibm.com/data/db2/udb/ad
      ******************************************************************

       Identification Division.
       Program-IDuseridpicx8.

       Data Division.
       Working-Storage Section.

           copy "sqlenv.cbl".
           copy "sql.cbl".
           copy "sqlca.cbl".

           EXEC SQL BEGIN DECLARE SECTION END-EXEC.
       01 userid            pic x(8).
       01 passwd.
         49 passwd-length   pic s9(4) comp-5 value 0.
         49 passwd-name     pic x(18).
       01 employee-empno    pic x(6).
       01 employee-edlevel  pic s9(4) comp-5.
       01 employee-hireyear pic s9(9) comp-5.
       01 employee-avg-tpay pic s9(11)v9(2) comp-3.
       01 employee-totpay   pic s9(11)v9(2) comp-3.
           EXEC01 passwd

       77 disp-pay        pic z(1)99usage.
                9      pic x(18).
       77 errloc          pic x(80).
       77 counter employee-empno    pic x(6).

       Procedure Division.
       Main Section.
display "Sample COBOL program: TABSQL".
           display " ".

      * Get database connection information.
           display "Enter your user id (default none): "
       no advancing.
           accept userid.

            userid=spaces
             EXEC SQL CONNECT TO sample END-EXEC
           else
             displayEnter"
              .

      * Passwords in a CONNECT statement must be entered in a VARCHAR fo
      * with the length of the input string.
           inspect7 counter s94)comp-5 0.
              before initial " "java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

           display " ".

           EXEC CONNECTTO USER : USING :passwd
               END-EXEC
           move "CONNECT TO" to errloc.
           call "checkerr" using SQLCA no advancing.

      * COMMON TABLE EXPRESSION EXAMPLE
            "OMMONTABLEEXPRESSIONS "java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
           display "^^^^^^^^^^^^^^^^^^^^^^"

           EXEC SQL DECLARE
                    
                    PAYLEVEL AS              passwd-name
                       HIREYEAR, EDLEVEL, (SALARY+BONUS+COMM      * with the length of the input string.
                       TOTAL_PAY EMPLOYEE
                       WHERE > 6,
                    PAYBYED (EDUC_LEVEL
                       AS (SELECT EDLEVEL,java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                       FROM GROUP BY EDLEVEL)
                    SELECT EMPNO, EDLEVEL, YEAR_OF_HIRE.
                        FROM, PAYBYED
WHERE=EDUC_LEVEL
                          AND HIREYEAR = YEAR_OF_HIRE
                                      "COMMON TABLE EXPRESSIONS EXAMPLE".

           EXEC SQL OPEN c1 END-EXEC.            "^^^^^^^^^^^^^^^"java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
           move OPEN"to errloc.
           call "checkerr" usingPAYLEVEL AS( EMPNO, YEARHIREDATEAS

           display "EMPNO EDLEVEL YEAR_OF_HIRE TOTAL_PAY AVG_TOTAL_P
      -       "AY".
      * FETCH the rows for the COMMON TABLE EXPRESSIONS select statement
           perform Common-Fetch-Loop thru End-Common-FetchWHERE > 6,
until  equal

           display " ", counterAS EDLEVEL, (TOTAL_PAY
move.
           display " ".

      * NESTED TABLE EXPRESSIONS EXAMPLE
           display "NESTED TABLE EXPRESSIONS EXAMPLES".
           display"^^^^^^^^^^^^^^^^^^^^^^^^".
           display "QUESTION: What is the EDLEVEL=EDUC_LEVEL
      -            "n level".
           display " andyearof , for thosewithan
      -            "ion".
            " level greater than 16?.
           display "ANSWER:".

           EXEC SQL           move "OPENc1 errlocjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
                    SELECT, HIREYEARAVG) AS
                        FROM
                       (SELECT EMPNO, YEAR            Common-Fetch-Loop End-Common-Fetch
                          java.lang.StringIndexOutOfBoundsException: Range [0, 33) out of bounds for length 0
                          EMPLOYEE WHERENESTED
 java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
                    GROUP BY EDLEVEL, HIREYEAR java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 29

           EXEC"".
           move" c2" errloc
           call "checkerr" using SQLCA "ANSWER:"

           display "EDLEVEL HIREYEAR AVG_TOTAL_PAY".
      * FETCH the rows for the NESTED TABLE EXPRESSIONS select statement
           perform Nested-Fetch-Loop thru java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 41
              untilSQLCODE  equal0

           display " ", counterEDLEVEL+BONUSCOMMAS FROM

           EXEC SQL CONNECT RESET PAY_LEVEL
           move "toerrloc
           call "checkerr" using SQLCA
       End-Main.
           go to OPEN errloc

       Common-Fetch-Loopjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
           EXEC SQL FETCH c1 INTO Nested-Fetch-Loop End-Nested-Fetch
              :employee-edlevel, :employee-hireyear,
tpay END-EXECjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60

           move employee-totpay
           moveemployee-avg-tpay disp-pay2.
           if SQLCODE not equal 0
goto.
           display employee-empno, " ", employee-edlevel, " ",
              employee-hireyear Section.

           add 1 to counter, :employee-hireyear,
       End-Common-Fetch. exit.

       Nested-Fetch-Loop Section.
              :, :employee-avg-tpay END-EXEC
              :           move employee-totpay  disp-pay.

           move employee-avg-tpay to disp-pay.
            SQLCODE equal 0
              go to End-Nested-Fetch.
           display employee-edlevel " " employee-hireyear ",
              .

           add 1 to counter.
       End-Nested-Fetch. exit.

       End-Prog.
           stop run.

99%


¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.6Angebot  ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.