how to fix this error:ddl statement interferred with query replan? - sql

database : vertica
when I use insert into.....select.... statement to add data, following error occurred:
notice : error encounterred in contriant validation
error : ddl statement interferred with query plan
hint : please reissue query

This error, although it is not the actual error, is pretty self explanatory. You tried to issue an INSERT statement, but there was another DDL statement that interfered (was holding a lock on the table) at the same time and so your INSERT statement was killed.
At this point you probably won't be able to see it any more, but in the future when you see this error, take note of the time that the statement was executed, then query the v_monitor.query_requests system table to see what other DDL statements were being executed at the same time.
If this was just an ad hoc INSERT statement, then the solution is to do exactly what the Vertica notice message said, re-issue the query. If this is part of a script or application logic, then you need to handle this error accordingly and add the logic to re-issue the statement again if this error is thrown.

Related

What is the behavior of cancel query on pgadmin3

I was irresponsibly typing SQL on a production ambient using pgadmin3 tool, suddenly I mistyped and execute a UPDATE sentence on a biggerImportantTable without WHERE. Then desperately I use cancel query button on pgadmin3. After I look at a small sample of the rows in the table and it seems good. But I'm not sure of the database integrity. What is the state of my boss database?.
The log of pgadmin3:
-- Executing query:
UPDATE schema.big_important_table SET important_field = NULL;
********** Error **********
ERROR: canceling statement due to user request
SQL state: 57014
If you cancel a DML statement (even with auto-commit enabled as pgAdmin does) the whole statement is rolled back.
So everything should be OK, nothing was changed.

Informix SQL update command error 746

I tried to update the field "contract_id" in the table "contract_scan_image".
However, the update was failed and an error "746: Field contract_id and type of contract_scan_image cannot be updated!" was shown.
My SQL command is:
update contract_scan_image
set contract_id = '14864730'
where contract_id = '1486473'
and type = 'RM'
and account = '00193400944'
Does anyone know what happened and how to fix it?
Error message -746 is for user-defined errors. It typically is used in stored procedures in a RAISE EXCEPTION statement:
RAISE EXCEPTION -746, 0, "Field contract_id and type of contract_scan_image cannot be updated!"
The actual message text for error -746 in the message files is:
%s
That is, it prints the string it is given as a string.
So, you are going to need to track down the triggers and stored procedures invoked by those triggers on the contract_scan_image table, and deduce from where the error is generated what you are doing wrong. Superficially, though, it appears that you are not allowed to alter the contract ID, yet that is what you are trying to do.
First things first, I would take a look at a list of Reserved words in SQL - https://drupal.org/node/141051
I would get in the habit of surrounding fields with `` See below:
update contract_scan_image
set `contract_id` = '14864730'
where `contract_id` = '1486473'
and `type` = 'RM'
and `account` = '00193400944'
** Note - type is a reserved word
The error is caused by something being triggered. Then no table can be modified by UPDATE command.
Finally I deleted the record I want to update. Then added back the modified record.
I copy the error description here from the net for reference.
BTW, I asked my supervisor and he said he did trigger something to cause this. (He didn't tell me how to un-trigger it...)
-746
THE SQL STATEMENT IN FUNCTION, TRIGGER, OR IN STORED PROCEDURE name VIOLATES THE NESTING SQL RESTRICTION
Explanation
If a table is being modified (by INSERT, DELETE, UPDATE, or MERGE), the table can not be accessed by the lower level nesting SQL statement.
If any table is being accessed by a SELECT statement, no table can be modified (by INSERT, DELETE, UPDATE, or MERGE) in any lower level nesting SQL statement.
System action
The SELECT, INSERT, DELETE, UPDATE or MERGE SQL statement failed.
Programmer response
Remove the failing statement from the named function, trigger or the stored procedure.
SQLSTATE
57053

Should I finalize my statements if the SQLite database is reported to be corrupt SQLITE_CORRUPT

I recieve SQLITE_CORRUPT error for the database being corrupt.
wrong # of entries in index sqlite_autoindex_Settings_1
In my code I have a try/finally clause in which I always try to always sqlite3_finalize my statements.
Apparently on a corrupted database trying to finalize the statement raises again SQLITE_CORRUPT.
Question: Should I finalize my statements if the database is reported to be corrupted?
before sqlite3_finalize or after every sqlite3_step use sqlite3_reset.
The sqlite3_reset(S) interface resets the prepared statement S back to the beginning of its program.
check whether you have sqlite3_reset after every sqlite3_step because this is one case that causes database to be corrupt. after preparing a statement with sqlite3_prepare and executing it with sqlite3_step,you need to always reset it with sqlite3_reset.
The sqlite3_reset(S) interface resets the prepared statement S back
to the beginning of its program.
before sqlite3_finalize or after every sqlite3_step use sqlite3_reset.
hope this solves your problem...!!!

Can dbms_errlog be used for SELECT queries?

Can the dbms_errlog function be used for SELECT queries?
I earlier encountered an error where Oracle is throwing an ORA-0722, i was trying to identify which column and possibly, row of a PL/SQL statement that was throwing that error. However i found out that dbms_errlog is native to only Oracle 10g and above.
In the case also, what alternatives do i have if i am using Oracle 9i?
DBMS_ERRLOG ist not a function, it is a PL/SQL package. It contains one procedure that creates an error table. To log errors to this error, you need to specify the "log errors" clause to your DML statements. From this description it should be obvious that this is tightly integrated with the transaction layer.
One way to reproduce similar behavior in earlier releases is to
Create your own error table
Create a PL/SQL procedure that inserts into that error table. To
make sure that the log is written in case of errors this procedure has to use
autonomous transactions.
The calls to log errors have to be explicitly added to the
corresponding exception handlers.

How to keep on transaction when it fails for some rows?

I want that when I execute a query for example DELETE FROM Contact, and an error is raised during the transaction it should delete the rows that are able to be deleted raising all the relevant errors for the rows that cannot be deleted.
For SQL Server you are not going to break the atomicity of the Delete command within a single statement - even issued outside of an explicit transaction, you are going to be acting within an implicit one - e.g. all or nothing as you have seen.
Within the realms of an explicit transaction an error will by default roll back the entire transaction, but this can be altered to just try and rollback the single statement that errored within the overall transaction (of multiple statements) the setting for this is SET XACT_ABORT.
Since your delete is a single statement, the XACT_ABORT can not help you - the line will error and the delete will be rolled back.
If you know the error condition you are going to face (such as a FK constraint violation, then you could ensure you delete has a suitable where clause to not attempt to delete rows that you know will generate an error.
If you're using MySQL you can take advantage of the DELETE IGNORE syntax.
This is a feature which will depend entirely on which flavour of database you are using. Some will have it and some won't.
For instance, Oracle offers us the ability to log DML errors in bulk. The example in the documentation uses an INSERT statement but the same principle applies to any DML statement.