Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how we run a embedded sql program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: how we run a embedded sql program
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    Post subject: Hi
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    Post subject: Re: how we run a embedded sql program
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: 147
Location: Columbia, MO

PostPosted: Fri May 04, 2007 3:11 am    Post subject: Re: how we run a embedded sql program
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us