In DB2 unable to alter column due to sqlcode=-668 - db2-luw

I have been getting the -668 error trying to expand a column from 8 octets to 20 octets. I got the -668 error which when I looked it up at ibm.com I got
"-668 THE COLUMN CANNOT BE ADDED TO THE TABLE BECAUSE THE TABLE HAS AN EDIT PROCEDURE DEFINED WITH ROW ATTRIBUTE SENSITIVITY"
So reading about an edit procedure, I see:
An edit procedure receives the entire row of a base table in internal Db2 format. It can transform the row when it is stored by an INSERT or UPDATE SQL statement or by the LOAD utility. An edit procedure can be defined as WITH ROW ATTRIBUTES or WITHOUT ROW ATTRIBUTES in a CREATE TABLE statement.
I did the reorg statement mentioned at
Failing update table in db2 with SQLCODE: -668, SQLSTATE: 57016, SQLERRMC: 7;
and then I could alter the table as I wished. However, the REORG seems to be more for defragging or somehow optimizing the table, but it does not say anything about removing an edit procedure. Could someone explain how there's an edit procedure, and further it has row sensitivity, yet there's no triggers, procedures in the schema that I can see. When I generated the DDL for the table, I didn't see anything suggesting an edit procedure.

Related

Hana: How to create a table type LIKE the type of another table?

I'm trying to create a table type which has a lot of fields, in SQLScript for a Hana machine.
I've tried some combinations of 'Like' and other keywords but it all comes out as a syntax error.
Furthermore, I could not find any hint of this in the SQLScript reference guide.
I've been creating tables LIKE [orignal table] with no data and inserting records into it - not practical :(
Thanks in advance.
Miguel
EDIT: to understand if the procedure 'get_object_definition' can be used with tables with case-sensitive names.
In this image we can see the procedure calls, with the error message; in the image after, the tables and table types in each of the schemas.
EDITED: I got it, have to call the procedure with ' " table_name " '
There is no specific command to create a type based on an existing table or another type.
What you can do is to get the definition of the table via
call get_object_definition ('<schema name>', '<table name>');
and edit the object creation statement to a CREATE TYPE statement. This is basically just changing the starting part of the statement and cutting away some parts at the end.

Delete data from table that is not reorganized (in db2)

I have a table that needs to be reorganised using the reorg command in DB#, However due to large size of the table, I am unable to do so. So I plan to delete entire data from the table and then do any reorg if required..
Is there any possible way for doing so?
I already used
DELETE FROM TABLE-NAME
and
TRUNCATE TABLE SCHAME-NAME.TABLE-NAME IMMEDIATE
But both the above queries aren't working and are giving the following error which is the one for reorg.
Error: DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016, SQLERRMC=7;DB2ADMIN.CERTIFICATE_TAB, DRIVER=3.50.152
SQLState: 57016
ErrorCode: -668

sql server 2012 t-sql change value in table

In a t-sql 2012 stored procedure, I would like to know if my solution to solve the problem is correct and/or if you have any other suggestion(s) on how I can complete the task I am listing below:
In an existing SQL Server 2012 stored procedure, there is a table called Atrn that is truncated every night. The table Atrn has a column called ABS that is populated with incorrect data.
The goal is to place the correct value into the ABS column that is located in when the stored procedure is executing.
Note: The goal is to fix the problem now since it is a production problem. The entire stored procedure that updates the dbo.Atrn table will be rewritten in the near future.
My plan is to:
create a temp table called #Atrnwork that will contain the columns
Atrnworkid int and ABSvalue double .
The value in the column called Atrnworkid in the #Atrnwork table will obtain its value from the key of the Atrn table, called atrnid by doing a select into. At the same time, the value for ABSvalue will be obtained by running some sql when the select into occurs
The main table called Atrn will be changed with a update statement that looks something like:
Update Atrn
set ABS = ABSvalue
join Atrn.atrnid = #Atrnwork.Atrnworkid
In all can you tell me what a good solution is to solve this problem and/or display some sql on how to solve the problem listed above?

Oracle SQL INSERT: Can I Report Out The Value That Triggers An Oracle Exception?

I am writing my first PL/SQL script.
In a batch-processing script I'm writing, I'm inserting data from a "comment" field of Table A into a column of Table B that has various integrity constraints (hence concerns about ORA-12899 - value too long, or ORA-02291 - value not allowed).
If an attempt to insert a value into Table B raises an exception, I'd like to use standard output to report not only that an insertion had to be skipped, but which contents of Table A resulted in a skipped insertion.
I'm aware that I could procedurally loop through Table A's data and essentially call 1 INSERT at a time, reporting out the value of any data that raised an exception to that call. But if possible, I'd like to stick closer to the principle of "letting SQL do its job."
Is there any way to display data from Table A when a straight-SQL "INSERT INTO {Table B} SELECT FROM {Table A}" raises an exception?
Note: I don't have any DDL permissions against the database and know that I can't get any; I only have DML & query like INSERT/UPDATE/SELECT. So solutions like "creating a log table" are out of the question, unfortunately.
Update: Second part to my question: Reading Question 1065829, I'm starting to think that even the skipping of invalid insertions and moving on with the valid insertions isn't possible with straight SQL and no DDL access (which I had presumed would be possible before writing my question above). It looks like I'm going to have to choose between iterating through Table A's rows, doing one INSERT call at a time, and asking for special DDL permissions. Is this correct?
Thank you!

how can i create a table and alter right after in a stored procedure?

My problem is that when I create the table within the stored procedure and I'm trying to alter a column, it says Invalid column name 'column_name'. As I know it happens, because the executions are parallel so the table does not exist when it tries to add the column. So is there any way that I could create the table and alter columns in a stored procedure at the same time? I've tried to do embedd stored procedures to create the table first, then alter column with another procedure within the first procedure, but I guess it still runs paralell and doesnt work. Thanks for help in advanced.