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

Is there any mistake int he following Dynamic SQL program


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

New User


Joined: 16 Dec 2004
Posts: 44
Location: Hyderabad

PostPosted: Mon Feb 28, 2005 11:38 am
Reply with quote

Please let me know if there are any mistakes in the below program. I did not get this executed when i tried to.

IDENTIFICATION DIVISION.
PROGRAM-ID. DYNAM1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-REC.
49 WS-LEN PIC S9(4) COMPT.
49 WS-TXT PIC X(100).
PROCEDURE DIVISION.
MOVE 45 TO WS-LEN.
MOVE 'DELETE * FROM EMP WHERE EMPNO = 1200' TO WS-TXT.
EXEC SQL
PREPARE DYN FROM WS-REC
END-EXEC.
EXEC SQL
EXECUTE DYN
END-EXEC.
STOP RUN.



In the above program EMP table is existing with a record 1200. I could run and execute error-free, but in the EMP table that particular record is not getting deleted. What is the error in the above pgm.

Also observe below........

after moving the statements like the above pgm i want to execute directly without preparing...... is the below one enough and correct

EXEC SQL
EXECUTE IMMEDIATE :WS-REC
END-EXEC.
Back to top
View user's profile Send private message
ashok_bln
Warnings : 1

New User


Joined: 19 Feb 2005
Posts: 5
Location: bangalore

PostPosted: Mon Feb 28, 2005 10:23 pm
Reply with quote

hello reddy

this is very small mistake.

u should not use * in the following sentence

'DELETE * FROM EMP WHERE EMPNO = 1200'

it should look like this

'DELETE FROM EMP WHERE EMPNO = 1200'

i think this will work

bye
ashok

080-23413623

bln_ashok@yahoo.co.in
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Fri Nov 11, 2005 5:47 pm
Reply with quote

hi frnd,
MOVE 1200 TO EMPNO.
MOVE 45 TO WS-LEN.
MOVE 'DELETE * FROM EMP WHERE EMPNO = :EMPNO' TO WS-TXT.

Hope it will work.. check out and let me know.
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 Using Dynamic file handler in the Fil... COBOL Programming 2
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
Search our Forums:

Back to Top