We have following query to get the records deleted on fk_data_table, and been found we weren’t able to, as because of 400k records.
Delete FROM BOM_LINK WHERE TEST_OBJECT_OID IN (SELECT DISTINCT TESTOBJECT_OID FROM TESTOBJECT WHERE TESTOBJECT.TESTOBJECTTYPE_OID = 3);
DB2 Error Code -495 https://www.sqlerror.de/db2_sql_error_-495_sqlstate_57051.html
I think what we can do is,
- We can write a function or procedure
- We can retrieve data by writing query by SELECT and CURSOR options, instead directly deleting
- While iterating CURSOR we can try deleting it. (I am not sure that in this way we can delete the row, anyway lets find this out)
- We can do periodical commit, instead of doing commit after extensive amount of deletion.
Could someone help us sorting out this issue which we are facing. Pointing to some SQL code snippets will help us a lot.
Unfortunately, Db2 for Z/OS doesn't allow to delete from a subselect.
I don't have Db2 for Z/OS at hand to check, but you may try the following:
Run
DELETE FROM BOM_LINK_Vuntil you get SQLSTATE = '02000' (no rows affected).Update:
The DELETE statement since v12 supports the
FETCH FIRSTclause.So, you may run the following without creating a view until you get SQLSTATE = '02000':