View previous topic :: View next topic
|
Author |
Message |
venkateswara rao.muppa
New User
Joined: 21 May 2007 Posts: 5 Location: hyderabad
|
|
|
|
hi, this is venkat
please reply me the programing structure of cobol+db2 in mainframes |
|
Back to top |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
Your question is very generic, I hope you want to know the essentials of a COBOL/DB2 program . Even a program which just gets a current date from DB2 can also be considered a COBOL/DB2 program. The structure depends on the complexity of the queries that are involved . You need to include the SQLCA in working storage area. If you have more than one row meeting the selection criteria then you have to first decalre a cursor in the working storage section, open the cursor, fetch the same and process the rows in a loop and close the cursor. While compiling you will have to use a precompiler like DSNHPC to compile the SQL code , compile the COBOL using IGYCRCTL, linkedit using IEWL or HEWL, bind the plan and run the program using IKJEFT01.
Should you need any more information do not hesitate to ask |
|
Back to top |
|
|
venkateswara rao.muppa
New User
Joined: 21 May 2007 Posts: 5 Location: hyderabad
|
|
|
|
hi,prasad v r k thanks for giving reply.
i am learner of mf. could you please give the syntax of program. |
|
Back to top |
|
|
prasadvrk
Active User
Joined: 31 May 2006 Posts: 200 Location: Netherlands
|
|
|
|
Quote: |
i am learner of mf. could you please give the syntax of program. |
If you mean the source code of program please find the same for a simple COBOL/DB2 program below, offcourse you have to validate the return codes where ever necessary.:
IDENTIFICATION DIVISION.
PROGRAM-ID. COBDB2.
AUTHOR. PRASAD VEMULAPALLI.
DATE-WRITTEN. JUNE 2007.
DATE-COMPILED.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT OUTFILE ASSIGN TO PRINTF.
DATA DIVISION.
FILE SECTION.
FD OUTFILE EXTERNAL
BLOCK 0 RECORDS.
01 OUTFILE-REC PIC X(132).
WORKING-STORAGE SECTION.
77 WS-EMPCODE PIC S(9).
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL
DECLARE CURSOR C1 FOR
SELECT EMPCODE FROM EMP WHERE EMPNAME = 'PRASAD'
END-EXEC.
PROCEDURE DIVISION.
OPEN OUTPUT OUTFILE
EXEC SQL
OPEN CURSOR C1
END-EXEC.
PERFORM FETCH-PARA UNTIL SQLCODE=+100.
CLOSE OUTFILE
STOP RUN.
FETCH-PARA.
EXEC SQL
FETCH CURSOR C1 INTO :WS-EMPCODE
END-EXEC
WRITE OUTREC FROM WS-EMP-CODE . |
|
Back to top |
|
|
venkateswara rao.muppa
New User
Joined: 21 May 2007 Posts: 5 Location: hyderabad
|
|
|
|
hi,Prasad V R K garu thanks for giving reply.
could you please reply compile jcl and run jcl for this cobol/db2 pgm. |
|
Back to top |
|
|
|