View previous topic :: View next topic
|
Author |
Message |
kishoreEC
New User
Joined: 17 Aug 2007 Posts: 2 Location: HYD
|
|
|
|
Hi,
My basic requirement is i want to have the count of number of records deleted from the table.
Currently,there are three tables: Tab1 ,Tab2 ,Tab3
Once a record in Tab1 is deleted,the record in TAb2 is also deleted.
Insert the data retrieved from Tab1 and Tab2 into Tab3 and delete the same data retrieved from Tab1 and Tab2.
Hence,i used a cursor which is below:
EXEC SQL
DECLARE DEL_MSGLOG_CUR CURSOR FOR
SELECT B.GML_IRN_TS FROM
GMS_MSG_LOG B , GMS_MSG_RESULTS C
WHERE B.GML_IRN_TS = C.GMR_IRN_TS
AND B.GML_IRN_TS < :WS-OLD-TIME
AND (B.GML_SQL_CDE > 0 OR
B.GML_RLS_VRFY_USE = 'N' OR
(B.GML_RLS_VRFY_USE = 'Y' AND
C.GMR_REPLY_RV_TS > :WS-INIT-TS) OR
(B.GML_RLS_VRFY_USE = 'Y' AND
C.GMR_SCAN_STA IN ('0','7','8','100') AND
C.GMR_REPLY_RV_TS = :WS-INIT-TS) OR
B.GML_SEND_APPL_ID LIKE 'HLTH%')
FOR UPDATE
END-EXEC.
the query i used for deleting is :
DELETE FROM GMS_MSG_LOG
WHERE CURRENT OF DEL_MSGLOG_CUR
and i am receving an error code of -510.Can u assist me i this rerard. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
I know it's a dumb question, but what did you learn from looking up the -510 error? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
This link is provided by IBM for those who just can't be bothered to access manuals.
In addition, for something as simple as a SQLCODE definition, you can download ABENDASSIT from this website (ibmmainframes), which is free and provides error code descriptions for db2, vsam, cobol, ims, etc........
since it is obvious that you do not bother to read the documentation, you would be confused by the description of a -510.
In short: you can not update, insert or delete from a CURSOR that returns read-only views. The definition of a read only view can be found in the next to the last post of this thread . |
|
Back to top |
|
|
kishoreEC
New User
Joined: 17 Aug 2007 Posts: 2 Location: HYD
|
|
|
|
I read the manuals,but overlooked the real meaning of the explaination.
What really confused me is that for deletion,previously,they used a direct 'DELETE' query instead of using Cursor.so,i was wondering why can;t it be doe this way.
I am sorry and thank you all for the assistance... |
|
Back to top |
|
|
|