31

While I was inserting data into a table (db2), I got this error:

Message: Operation not allowed for reason code "7" on 
table "ELSAG.ICGR1106".. SQLCODE=-668, SQLSTATE=57016, DRIVER=3.50.152,...

when I googled it, I found that the previous ALTER TABLE statement attempted to add a column to a table that has an edit procedure that is defined with row attribute sensitivity. No columns can be added to this table.

Is there is a way to rectify it?

Once I drop and re-create the table I can insert again.

Thanks in advance.

Alex Pakka
  • 9,466
  • 3
  • 45
  • 69
user438159
  • 497
  • 4
  • 7
  • 9

5 Answers5

70

To add to James' answer and save people time looking around, you could execute

CALL SYSPROC.ADMIN_CMD('REORG TABLE MY_TABLE_NAME')

via any available SQL client (i.e. even over ODBC or JDBC connection) to rectify this problem. However, the connection has to be in autocommit mode and you have to have admin privileges to execute this command.

I highly recommend to read the documentation on REORG before calling it.

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
Alex Pakka
  • 9,466
  • 3
  • 45
  • 69
11

According to this: SQL0668

You have done some alteration to the table which requires a REORG before you can further update the table.

Run the REORG utility against the table and you should be OK.

James Anderson
  • 27,109
  • 7
  • 50
  • 78
  • Also under DB2 LUW it could be that a "SET INTEGRITY" is required after "ALTER TABLE" or "LOAD" has occurred. – Turophile Apr 30 '14 at 05:11
7

CALL SYSPROC.ADMIN_CMD('REORG TABLE TABLE_NAME') solves the problem

Ankireddy Polu
  • 1,824
  • 16
  • 16
3
SELECT REORG_PENDING FROM SYSIBMADM.ADMINTABINFO where TABSCHEMA = '<schema_name>' and tabname = '<table_name>';

If above query returns Y Then run below query:

call sysproc.admin_cmd('reorg table <schema_name>.<table_name>');

For more info visit: SQL0668N Operating not allowed for reason code '7'

DaveL17
  • 1,673
  • 7
  • 24
  • 38
0

I turned off integrity checks on some table and got that error message afterwards when altering data. This here generated the statements which helped:

select 'SET INTEGRITY FOR ' || rtrim(tabname) || ' IMMEDIATE CHECKED;' 
from syscat.tables 
where CONST_CHECKED like '%N%' 
  or status != 'N'
  or access_mode != 'F'
with ur;
koem
  • 554
  • 4
  • 24