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
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts pre-compiler for program in an HFS Pedro DB2 0 Fri Jun 23, 2017 11:13 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Compiling program in endeavor for tra... RALAKKAL Compuware & Other Tools 4 Mon Jun 05, 2017 8:27 pm

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