IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

how we run a embedded sql program


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
achusarath

New User


Joined: 21 Mar 2007
Posts: 26
Location: kerala

PostPosted: Wed May 02, 2007 6:04 pm
Reply with quote

hi ,

i want to run a cobol pgm which calls an embedded sql pgm. so how can i run that pgm. the code is shown below
Code:
   IDENTIFICATION DIVISION.   
 PROGRAM-ID. XYZ.           
 DATA DIVISION.             
 WORKING-STORAGE SECTION.   
 01 A PIC 9(2) VALUE IS 10. 
 01 B PIC 9(2) VALUE IS 04. 
 01 C PIC 9(2) .             
 01 D PIC X(10).             
 PROCEDURE DIVISION.         
 P1.                         
     COMPUTE C = A + B.     
     DISPLAY C.             
     MOVE 'D3COB' TO D.     
     CALL D.                 
     STOP RUN.               



called pgm

Code:

 IDENTIFICATION DIVISION.                                         
 PROGRAM-ID. D3COB.                                               
 DATA DIVISION.                                                   
 WORKING-STORAGE SECTION.                                         
     EXEC SQL                                                     
     INCLUDE SQLCA                                               
     END-EXEC.                                                   
     EXEC SQL                                                     
     INCLUDE DCLM1                                               
     END-EXEC.                                                   
 01 S1.                                                           
 49 LEN PIC S9(4)  COMP.                                         
 49 TXT PIC X(120).                                               
 01 C1 PIC S9(3) SIGN LEADING SEPARATE CHARACTER.                 
 PROCEDURE DIVISION.                                             
 P1.                                                             
     MOVE 'UPDATE EMPTABLE1 SET EMPCITY = ? WHERE EMPID=?' TO TXT.
MOVE 51 TO LEN.
      MOVE 'NEW' TO EMPCITY.                   
      MOVE 'A2' TO EMPID.                     
      EXEC SQL                                 
       PREPARE SQLOBJ FROM :S1                 
      END-EXEC.                               
      EXEC SQL                                 
       EXECUTE SQLOBJ USING :EMPCITY,:EMPID   
      END-EXEC.                               
       MOVE SQLCODE TO C1.                     
       DISPLAY C1.                             
  EXIT-PROGRAM.                               



so my question is can we execute a simpl cobol pgm that contain a call stmt which calls a embedded sql pgm.
Back to top
View user's profile Send private message
mkk157

Active User


Joined: 17 May 2006
Posts: 310

PostPosted: Wed May 02, 2007 7:51 pm
Reply with quote

Hi achusarath,

Before compiling the Main COBOL program, U need to precompile the sub-program which contains the embedded SQL statements.


Correct me If I am wrong.
Back to top
View user's profile Send private message
anujageorge

New User


Joined: 28 Mar 2007
Posts: 4
Location: Cochin

PostPosted: Thu May 03, 2007 11:51 am
Reply with quote

HI,


but my pgm is not embedded.... only my called pgm is embedded...
so how can we compile with a db2 compiler...
Back to top
View user's profile Send private message
socker_dad

Active User


Joined: 05 Dec 2006
Posts: 177
Location: Seattle, WA

PostPosted: Fri May 04, 2007 3:11 am
Reply with quote

If I understand you correctly, you have a standard COBOL program which calls a DB2 subprogram.

The subprogram has been previously compiled, linked, etc. as a stand alone module.

At our site, our calling programs are compiled, linked and bound under a DB2 package and plan even though they have no SQL in them. According to our systems people, this gives them the ability to call and use these SQL modules.
Back to top
View user's profile Send private message
priyadutta1984

New User


Joined: 02 Apr 2007
Posts: 11
Location: chennai

PostPosted: Fri May 04, 2007 11:31 am
Reply with quote

well,
the sub program which have sql is need to be precompile.once u finish the process then execute main program normal way. no need for precompilation of main program.

cheers
priya
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top