Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

db2 SQLCODE -668 when inserting

Tags:

sql

db2

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.

like image 607
user438159 Avatar asked Sep 28 '11 03:09

user438159


People also ask

Can you use a select statement in an INSERT statement?

You can use a select-statement within an INSERT statement to insert zero, one, or more rows into a table from the result table of the select-statement. The select-statement embedded in the INSERT statement is no different from the select-statement you use to retrieve data.

How do I INSERT a special character in DB2?

There are no "special characters" in SQL databases (including DB2), unless they are special to the application doing the inserting. If you are using parameterized statements: INSERT INTO mytable (mycol) VALUES (?) , anything goes.

Can we use INSERT and select together?

In previous examples, we either specified specific values in the INSERT INTO statement or used INSERT INTO SELECT to get records from the source table and insert it into the destination table. We can combine both columns and defined values in the SQL INSERT INTO SELECT statement.


3 Answers

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.

like image 57
Alex Pakka Avatar answered Sep 23 '22 05:09

Alex Pakka


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

like image 38
Ankireddy Polu Avatar answered Sep 21 '22 05:09

Ankireddy Polu


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.

like image 32
James Anderson Avatar answered Sep 23 '22 05:09

James Anderson