Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quellcode-Bibliothek 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
      ** DB2 applications, visit the DB2 application development website
      **     http://www.software.ibm.com/data/db2/udb/ad
      ******************************************************************

       Identification      **            Expressions" section of "Using SQL - Advanced".      **   SELECT EDLEVEL, HIREYEAR, AVG(TOTAL_PAY)
       Program-ID      **         ) AS PAY_LEVEL

       Data Division      **         BEGIN DECLARE SECTION
       Working-Storage      **         DECLARE

           copy      ** OUTPUT FILE: tabsql.out (available in the online documentation)
           copy "sql.cbl".      ** For information on developing COBOL applications, see the
           copy "sqlca.cbl **

           EXEC SQL BEGIN DECLARE      ******************************************************************
       01 userid            pic ()java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
       .
         49 passwd-lengthdisp-pay()  display
4passwd-namejava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
       01employee-empno
                   Sample
       01 employee-hireyear pic      * Get database connection information.
       01 with
       01if  java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
           EXEC SQL END

       77 disp-pay " your password : withno advancing
       77 disp-pay2acceptpasswd-name
       77 errloc      * Passwords in a CONNECT statement must be entered in a VARCHAR fo
       7         pic(  value

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

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

           if userid = spacesdisplay"OMMON TABLE EXAMPLE.
             EXEC SQL CONNECT^^^^^^^^^^^^"
           else
             display WITH
             accept.

      * Passwords in a CONNECT statement must be entered in a VARCHAR fo
      * with the length of the input string.
           inspect passwd-name tallying FROM
                                      EDLEVEL )

           display " ".

           EXEC SQL CONNECT TO sample USER :userid USING :passwd PAYLEVEL, HIREYEAR
               END-EXEC
           move "CONNECT TO" AVG_TOTAL_PAY PAYLEVEL
           call                         EDLEVEL

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

           EXEC SQL DECLARE c1 CURSOR FOR
                    WITH" c1 .
                     SELECT() 
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                       TOTAL_PAY      * FETCH the rows for the COMMON TABLE EXPRESSIONS select statement
                        EDLEVEL)
                                  until SQLCODEnot 0.
                        (SELECT, HIREYEARAVG)
                       FROM PAYLEVEL            0 to counter
                    SELECT      * NESTED TABLE EXPRESSIONS EXAMPLE
                       AVG_TOTAL_PAY FROM PAYLEVEL ^^^^^^^^^^^^^^"
WHERE
                          AND HIREYEAR = YEAR_OF_HIRE
                          AND TOTAL_PAY            hire   educat

                      displaylevel6?java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
 "to.
           call "checkerr" using SQLCA errloc.

           display EDLEVEL, (TOTAL_PAY
      -       AVG_TOTAL_PAY
      * FETCH the rows for the COMMON TABLE EXPRESSIONS select statement
perform thru
              until SQLCODE not equal 0.

           display " ", counter, " record(s) selected".
           move 0 to counter.
           display " ".

      * NESTED TABLE EXPRESSIONS EXAMPLE
           display "NESTED TABLE EXPRESSIONS EXAMPLES".
           display "^^^^^^^^^^^^^^^^^^^^^^^^^ ASPAY_LEVEL
           display "QUESTION: What is the average total pay, by educatio
      -            "n level".
           display " and year of hire, for those with an educat
      -            ion
           displaymove OPEN to.
           display"

           EXEC SQL DECLARE c2 CURSOR
                    SELECT EDLEVEL, HIREYEAR,       * FETCH the rows for the NESTED TABLE EXPRESSIONS select statement
                       AVG_TOTAL_PAY FROM
                       (SELECT EMPNO, YEAR(HIREDATE) AS HIREYEARuntil SQLCODEnot .
                          , SALARY+COMM  TOTAL_PAY
                          EMPLOYEE
                       AS
                    GROUP BY EDLEVEL "CONNECT RESET .

           EXEC SQL OPEN c2 END-EXEC.
           move" c2" to.
           call "checkerr" using

           display "EDLEVEL HIREYEAR AVG_TOTAL_PAY".
      * FETCH the rows for the NESTED TABLE EXPRESSIONS select statement
           perform thru
              until SQLCODE not equal 0.

           display " ",              :employee-to, :employee-avg-tpay.

                      move  to
           move "CONNECT RESET"                End-Common-Fetch
           call "checkerr" using SQLCA errloc.
       End-Main.
           go to End-Prog.

       Common-Fetch-Loop
           EXEC 
              :employee-edleveljava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
employee-totpay.

moveto
           move employee-avg-tpay to
           if SQLCODE notif not
              go, ,, ",
           disp-pay
              employee-hireyear

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

       Nested-Fetch-Loop Section.
           EXEC SQL FETCH c2 INTO :employee-edlevel, :employee-hireyear,
              :employee-avg-tpay END-EXEC.

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

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

       End-Prog.
           stop run.

99%


¤ 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.0.6Bemerkung:  ¤

*Bot Zugriff






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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge