On dropping a unique constraint, following error occurs,
ORA-04098: trigger 'SYS.XDB_PI_TRIG' is invalid and failed re-validation
Having no permission to recompile this trigger.
What could be the problem here and is there any way we can solve this?
This error reflects a compilation/authorization failure for a mentioned trigger. This trigger was invalid so failed to be retrieved for execution. You can run
SHOW ERRORS TRIGGER SYS.XDB_PI_TRIG;
in order to have a bigger picture of that error.
Trigger may need to be recompiled. Running:
alter trigger SYS.XDB_PI_TRIG compile
will recompile this trigger.
Common case is when user has privileges only to run and not change respective triggers. In that case you may need to recompile the Trigger as SYSDBA.
I wouldthink that you may be dropping a primary key check what constraint your dropping. if your dropping a pk and its being used as a foreign key then this would invalidate the trigger.
Found a solution to this,
The XDB Schema is invalid for the Database. So we are unable to drop any objects in this Database. So making the XDB schema valid, has solved this problem.
Thanks for your answers!
Related
I've got a postgres database that I'm trying to clean up with drop schema public cascade. The data on it is not that important and I never made any backups. I'm just trying to rebuild it. However, it seems an error I made earlier is causing the drop command to fail.
When I run drop schema public cascade, I get a
ERROR: cache lookup failed for constraint XXXXX. I checked pg_constraints and it doesn't exist. It's probably linked to a table/index that doesn't exist anymore. Is there anyway I can get rid of this persisting/non-existing constraint so I can cleanup the database?
Perhaps it is enough to remove the dependency:
DELETE FROM pg_depend
WHERE objid = XXXXX;
Thank you in advance for your help.
I am getting the below error while creating a user in Odoo, initially, it was working fine but suddenly it started showing this error:
The operation cannot be completed: another model requires the record
being deleted. If possible, archive it instead.
Model: Unknown (Unknown), Constraint:
digest_digest_res_users_rel_digest_digest_id_fkey
Please provide me help
It seems you have installed, uninstalled module on the database and it stored constraint in the table. So if we drop that constraint, system will work smoothly.
You may try with this:
Login in your postgresql database.
Copy this query alter table digest_digest drop constraint and press tab and check if you find above digest_digest_res_users_rel_digest_digest_id_fkey constraint.
Our HSQLDB database has a FK constraint from the PAYMENTS table to the USERS table. What we did wrong here was create a constraint without giving it a specific name. This causes HSQLDB to generate a name for you, e.g. SYS_FK_10985.
What I did was write a custom change set for Liquibase that will find the name of the index and drop it. What the script does is pretty simple:
SELECT constraint_name FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE WHERE TABLE_NAME= 'PAYMENTS' AND COLUMN_NAME= 'USER_ID';
If found, it is dropped by the following query executed in that same change set:
ALTER TABLE PAYMENTS DROP CONSTRAINT SYS_FK_10985;
The patch is executed successfully and the drop constraint command is added to the .log file of HSQLDB, however, when we then want to run the HSQLDB instance it throws an error saying the object could not be found.
The log file looks as follows:
The major problem is that the wrong index (a non-existent one) is dropped in the log file, which naturally causes HSQLDB to throw an exception. What is even worse: when the exception occurs, everything after that line is deleted from the log file and not even stored in the .data file.
Is it possible the constraint name changes causing the change set to get a wrong name?
You need to perform a CHECKPOINT right after this operation, or any series of structural changes.
The CHECKPOINT persists the changes into the .script file and deletes the .log file, avoiding the issue to arise.
I would like to mark a record as deleted instead of actually deleting a record.
My intention is to use an instead of trigger, but I am getting an SQLException that neither I nor Google know how to solve this.
My code:
CREATE TRIGGER IF NOT EXISTS <Trigger>
INSTEAD OF DELETE ON <Table>
FOR EACH ROW
BEGIN
UPDATE <Table>
SET Status = 'D'
WHERE ID = old.ID;
END
My Error:
java.sql.SQLException: cannot create INSTEAD OF trigger on table: main.<Table>
at org.sqlite.NativeDB.throwex(NativeDB.java:210)
at org.sqlite.NativeDB._exec(Native Method)
at org.sqlite.Stmt.executeUpdate(Stmt.java:152)
Assist me, please?
EDIT:
What I really wanted was to activate foreign key enforcement.
Refer here: How do you enforce foreign key constraints in SQLite through Java?
You cannot use INSTEAD OF triggers on tables, and when RAISE-ing an error in BEFORE/AFTER triggers, any updates done in the trigger would also be rolled back.
You could rename your table, create a view for that table, and create lots of INSTEAD OF triggers to implement all the INSERT/UPDATE/DELETE operations.
However, it would be much easier to change your program to just execute the UPDATE when it wants to mark some record.
Instead of triggers are intended for use with views so that you can specify the underlying tables that an action should be carried out on when an insert, update our delete is issued on the view itself.
One thing you could try is to do a before delete trigger then raise an exception. The only thing is I'm not sure if this would also interfere with the update. Maybe worth a try though:
SELECT RAISE(ABORT, 'Prevent delete');
I'm trying to drop a constraint on a DB table, something like:
ALTER TABLE MyTable drop CONSTRAINT FK_MyTable_AnotherTable
But the execution just runs and runs. If I stop it I see:
Msg 3727, Level 16, State 0, Line 2
Could not drop constraint. See previous errors.
Web search throws up various pages but note that the constraint is properly named and I am trying to remove it using the correct name
I was having the same issue on SQL Server 2008 R2, I solved my problem with below line hopefully it will work for someone else as well :)
Alter Table [Table Name]
DROP Column [Column Name]
Found a way to sort this, although I don't understand why it was necessary.
Have been able to drop the constraint by disabling it first:
ALTER MyTable NOCHECK CONSTRAINT FK_MyTable_AnotherTable
The drop then completes fine
Would still welcome any comments on the reason why this is necessary
Verify that you've not already dropped the constraint, like:
SELECT OBJECT_ID('FK_MyTable_AnotherTable')
If this returns null, your constraint no longer exists. That would explain the error message.
I had same problem.
The reason was that I made a mistake in my cursor statement, which was iterating some constraint I was to drop.
So this error occurred when the constraint was actually removed in the same transaction. Then I did a rollback and checked if it existed: it did (of course, after rollback!).
Check if it really exists at the moment of dropping.