Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Is there any mistake int he following Dynamic SQL program

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Is there any mistake int he following Dynamic SQL program
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    Post subject:
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: 680
Location: NJ

PostPosted: Fri Nov 11, 2005 5:47 pm    Post subject: delete statement
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    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
This topic is locked: you cannot edit posts or make replies. Rexx code to find greater then symobl... Bharath Vikraman CLIST & REXX 8 Tue May 29, 2018 9:40 am
No new posts How to convert 2 bytes into single by... pkmurali DB2 6 Fri May 25, 2018 1:41 pm
No new posts Cobol program till a given time or fo... ankita agarwal COBOL Programming 7 Fri May 18, 2018 2:24 pm
No new posts Program usage statistics? John Poulakos CICS 6 Wed May 16, 2018 2:22 am
No new posts Error executing Java program in OSGI ... danik56 CICS 0 Thu Apr 26, 2018 12:16 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us