Results 1 to 7 of 7
  1. #1
    Join Date
    Jul 2007
    Posts
    4

    Unanswered: COBOl DB2 connectivity on windows

    hi everone,

    I want to connect cobol with Db2 on windows .some helpful details are:

    COBOL compiler:Fujitsu 3.0(student version)
    DB2:Windows Version
    OS:Windows XP professional with SP2

    Please provide me steps and some simple example to do this.

    -MS

  2. #2
    Join Date
    Jan 2003
    Posts
    1,605
    Hi,
    can you provide more info about DB2 database?
    1. database version, execute command in DB2 Command Window: db2level
    2. what is the type of database: db2licm -l

    Regards,
    Grofaty

  3. #3
    Join Date
    Jul 2007
    Posts
    4
    Hi,

    here is the info u asked

    Version of DB2B2 v9.1.0.356
    Licencse Type:Trial

    -MS

  4. #4
    Join Date
    Jun 2006
    Posts
    471
    most samples/syntax is explained in
    application development guide client
    samples are shipped in samples directory below sqllib - also for cobol
    Best Regards, Guy Przytula
    DB2 UDB LUW certified V6/7/8

  5. #5
    Join Date
    Jul 2007
    Posts
    4
    hi all,

    I am trying a sample program with Fujitsu compiler ,it fails at compilation
    I attached a doc named error containing the print screen of error.

    code which is used for compilation is follows:
    please help

    Code:
    000010 IDENTIFICATION DIVISION.
    000020 PROGRAM-ID.    SAMPLE10.
    000030 ENVIRONMENT    DIVISION.
    000040 DATA           DIVISION.
    000050 WORKING-STORAGE SECTION.
    000060     EXEC SQL BEGIN DECLARE SECTION END-EXEC. 
    000070 01 PNO          PIC S9(4) COMP-5.
    000080 01 PNAME        PIC X(20).
    000090 01 STOCKS       PIC S9(9) COMP-5.
    000100 01 STOCKER      PIC S9(4) COMP-5.
    000110 01 SQLSTATE     PIC X(5).
    000120 01 SQLMSG       PIC X(128).
    000130     EXEC SQL END DECLARE SECTION END-EXEC.
    000140 PROCEDURE DIVISION.
    000150* EMBEDDED EXCEPTION DECLARATION
    000160     EXEC SQL
    000170       WHENEVER NOT FOUND GO TO :P-END
    000180     END-EXEC.
    000190* DECLARE CURSOR
    000200     EXEC SQL
    000210       DECLARE CUR1 CURSOR FOR SELECT * FROM STOCK
    000220     END-EXEC.
    000230 P-START.
    000240* CONNECT TO THE DATABASE ON THE DEFAULT SERVER.
    000250     EXEC SQL
    000260       CONNECT TO DEFAULT
    000270     END-EXEC.  
    000280*-----------------------------------------------------------------
    000290*******************
    000300****   NOTES   ****
    000310*******************
    000320*    This program does not support Microsoft(R) SQL Server(TM) to
    000330*    connect to a database.
    000340*    If you use Microsoft(R) SQL Server(TM) to connect to a database,
    000350*    correct the following lines
    000360*
    000370*      004500* DETERMINE CONNECTION
    000380*      004600     IF SQLSTATE = "00000" THEN
    000390*                                ~~~~~
    000400*     to read as follows
    000410*      004500* DETERMINE CONNECTION
    000420*      004600     IF SQLSTATE = "01000" THEN
    000430*                                ~~~~~
    000440*-----------------------------------------------------------------
    000450* DETERMINE CONNECTION
    000460     IF SQLSTATE = "00000" THEN
    000470       DISPLAY "SUCCESSFUL CONNECTION WITH DATABASE."
    000480       DISPLAY " "
    000490     ELSE
    000500       DISPLAY "UNSUCCESSFUL CONNECTION WITH DATABASE."
    000510       DISPLAY "       SQLSTATE : " SQLSTATE
    000520       DISPLAY "       SQLMSG   : " SQLMSG
    000530       GO TO END-PROC
    000540     END-IF.
    000550       
    000560* OPEN THE CURSOR. 
    000570     EXEC SQL
    000580       OPEN CUR1 
    000590     END-EXEC.  
    000600 P-LOOP.
    000610* FETCH THE DATA.
    000620     EXEC SQL
    000630       FETCH CUR1
    000640       INTO :PNO,:PNAME,:STOCKS,:STOCKER
    000650     END-EXEC.  
    000660     DISPLAY " PRODUCT-NO     =  "  PNO.
    000670     DISPLAY " PRODUCT-NAME   =  "  PNAME.
    000680     DISPLAY " STOCK-COUNT    =  "  STOCKS.
    000690     DISPLAY " STOCKER-NO     =  "  STOCKER.
    000700     DISPLAY " ".
    000710
    000720     GO TO P-LOOP.
    000730
    000740 P-END.
    000750* CLOSE THE CURSOR.
    000760     EXEC SQL
    000770       CLOSE CUR1
    000780     END-EXEC.  
    000790* END THE TRANSACTION.
    000800     EXEC SQL
    000810       ROLLBACK WORK
    000820     END-EXEC.
    000830* DISCONNECT FROM THE DATABASE.
    000840     EXEC SQL
    000850       DISCONNECT DEFAULT
    000860     END-EXEC.
    000870
    000880 END-PROC.
    000890     DISPLAY "END OF SESSION".
    000900     STOP RUN.
    000910
    000920*-----------------------------------------------------------------
    000930* Microsoft is a registered trademark of Microsoft Corporation in
    000940* the USA and other countries.
    000950* SQL Server is a registered trademark of Microsoft Corporation in
    000960* the USA.
    000970*-----------------------------------------------------------------
    Attached Files Attached Files

  6. #6
    Join Date
    Jun 2006
    Posts
    471
    have you looked at this thread :
    http://www.dbforums.com/showthread.php?t=801502
    Best Regards, Guy Przytula
    DB2 UDB LUW certified V6/7/8

  7. #7
    Join Date
    Feb 2012
    Posts
    1
    Quote Originally Posted by guyprzytula View Post
    have you looked at this thread :
    http://www.dbforums.com/showthread.php?t=801502
    thanks this helped!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •