AWS DMS oracle full load failed - oracle

I am running an RDS oracle 12 TO RDS Oracle 12. But my task fails with the below error.Could not understand what is the issue.
Last Error Failed to connect to database. Task error notification
received from subtask 2, thread 1 [reptask/replicationtask.c:2822]
[1020414] Failed executing create PK statement: ALTER TABLE
"1234"."MST" ADD CONSTRAINT "SYS_C0011324" PRIMARY KEY ( "SEC",
"TARIFF" ); ORA-02264: name already used by an existing constraint ;
Handling new table '1234'.'MST' failed; Endpoint is disconnected;
Error executing data handler; Stream component failed at subtask 2,
component st_2_GP7OZL3BRFLFYLJHGB3UF4TNMYELVSRAJMZIA; Stream component
'st_2_GP7OZL3BRFLFYLJH3UF4TNMYELVSRCXAJMZIA' terminated
[reptask/replicationtask.c:2829] [1020414] Stop Reason
RECOVERABLE_ERROR Error Level RECOVERABLE

ORA-02264: name already used by an existing constraint
Cause: The specified constraint name has to be unique.
Action: Specify a unique constraint name for the constraint.
Your constraint name "SYS_C0011324" is system-generated, and appears to overlap with a different system-generated constraint name in the target database. You will need to change the constraint name in one database or the other to avoid the conflict, then try your load again.

Related

Spring Boot: How do I specify execute order of different schema.sql files?

I have created a table that has a foreign key constraint on spring-session-jdbc's spring_session table. The main motivation is that spring-session would delete the rows so that it would cascade and delete entries associated with the actual session. It became a "only works on my machine" problem because only me have had the table already in place when I start the development server. It would only work if others comment out the table first, initialize the server, then revert and do it again. Otherwise, nested exception is java.sql.SQLException: Failed to open the referenced table 'spring_session'.
I think the solution is to specify the run order of (or dependencies between) the initialization sql files. I cannot find that setting after some searching, so I am here.
schema.sql:
drop table if exists foo;
create table if not exists foo (
sid char(36) not null,
foreign key (sid) references spring_session (session_id) on delete cascade,
-- other columns and constraints
);
Possible workarounds:
Workaround #1: put an alter table add constraint statement like this in data.sql.
Workaround #2: grab spring-session-jdbc's schema.sql and put it into my schema.sql, then set spring.session.jdbc.initialize-schema=never in application.properties.
U can try flyway,it can manage your init sql files by giving them a version number. And it can record which sql have been executed, so if add another sql files, it will excute the sql you added, pass the others that have been executed.

I tried to delete some items from the SQL database but I got an integrity constraint error

I tried the following query to delete some rows from the SQL database but it's showing following error:
Query:
Delete From Document_Type where Doc_Type_id='case'
This is the error:
Error starting at line : 4 in command -
delete From Document_Type where Doc_Type_Desc='Case'
Error report -
SQL Error: ORA-02292: integrity constraint (NW_DEV_281015.FK_COMMENTS_DOCUMENT_TYPE6) violated - child record found
02292. 00000 - "integrity constraint (%s.%s) violated - child record found"
*Cause: attempted to delete a parent key value that had a foreign dependency.
*Action: delete dependencies first then parent or disable constraint.
How to solve this problem
I assume Oracle by the error.
Like the error message said, you have a constraint that forces the child table to be connected. So first, delete the same records from the child table:
DELETE FROM Child_Table t
WHERE t.<FK> IN(SELECT s.PK FROM Document_Type s where s.Doc_Type_Desc='Case')
Then do you delete. Or alternativly , disable the constraint :
alter table
table_name
DISABLE constraint
constraint_name;

FOREIGN KEY ON DELETE RESTRICT Error - Oracle

Lately I have been trying to add the following foreign key in the table, with the RESTRICT Clause in Oracle with the following command.:
ALTER TABLE
Employee_SalHead
ADD CONSTRAINT PAYROLL_SHEAD_FKEY FOREIGN KEY
(
SalHead_ID
)
REFERENCES SalHead
(
SalHead_ID
)
ON DELETE RESTRICT ENABLE;
This gave me the following error:
Error starting at line : 11 in command - ALTER TABLE Employee_SalHead ADD
CONSTRAINT PAYROLL_SHEAD_FKEY FOREIGN KEY ( SalHead_ID )
REFERENCES SalHead ( SalHead_ID ) ON DELETE RESTRICT ENABLE
Error report - SQL Error: ORA-00905: missing keyword
00905. 00000 - "missing keyword"
*Cause:
*Action:
Also if I try the same through Oracle SQL developer, I get only the options Set Null, Cascade and No Action Only.
Oracle only supports ON DELETE SET NULL and ON DELETE CASCADE. You can achieve your requirement by simply doing the below query. No need to mention ON DELETE RESTRICT
ALTER TABLE Employee_SalHead
ADD CONSTRAINT PAYROLL_SHEAD_FKEY FOREIGN KEY(SalHead_ID)
REFERENCES SalHead(SalHead_ID);
ON DELETE NO ACTION is Default.
From Documentation
The No Action (default) option specifies that referenced key values cannot be updated or deleted if the resulting data would violate a referential integrity constraint. For example, if a primary key value is referenced by a value in the foreign key, then the referenced primary key value cannot be deleted because of the dependent data.

Oracle BPEL DB Adapter constraint exception when writing in two tables - suddenly broken

I've got a Oracle BPEL process running on WebLogic which is writing in two tables using Database Adapters.
There are two tables, TableA and TableB. TableB has a foreign key to TableA.
I the process I create an entry in TableA with A_ID. When I create an entry in TableB using A_ID as a FK I get a constraint exception.
What is weird, this worked last week and now, using the same data, I get the error.
The datasource is set up as a standard - non-XA datasource.
This is the exception that is thrown:
<env:Fault>
<faultcode>env:Server</faultcode>
<faultstring>Exception occured when binding was invoked.
Exception occured during invocation of JCA binding: "JCA Binding execute of
Reference operation 'insert' failed due to: DBWriteInteractionSpec Execute
Failed Exception.
insert failed. Descriptor name: [Datawarehouse.TableB].
Caused by java.sql.BatchUpdateException: ORA-02291: integrity constraint
(DWH.TABLE_A_FK) violated - parent key not found
.
".
The invoked JCA adapter raised a resource exception.
Please examine the above error message carefully to determine a resolution.
</faultstring>
<faultactor/>
<detail>
<exception>ORA-02291: integrity constraint (DWH.TABLE_A_FK) violated - parent key not found</exception>
</detail>
</env:Fault>
This has nothing to do with Oracle BPEL. For some reason, either the insert onto Table A is not successful or the insert on to Table A is not visible to Table B (second insert being in a different transaction).

primary key column were entried duplicately when load data from user file

Oracle 11g
step 1.
create table pur_order(
po_number number primary key,
po_date date,
po_vendor number,
:)
step 2.load data with Enterprise Manager 11g from a user file podata.txt content like:
1 25-JUN-2011 1001
2 26-JUN-2011 1002
3 27-JUN-2011 1003
1 27-JUN-2011 1001
2 28-JUN-2011 1002
step 3. the loading process finished successfully.
table content is just like above
problem is as I have already defined po_number as primary key,why duplicate values of po_number still be able to be loaded?
Most likely this method of import uses the SQL*Loader utility with the Direct Path Load method. This disables some integrity constraints as explained in the documentation:
Integrity constraints that depend on other rows or tables, such as referential constraints, are disabled before the direct path load and must be reenabled afterwards. If REENABLE is specified, SQL*Loader can reenable them automatically at the end of the load. When the constraints are reenabled, the entire table is checked. Any rows that fail this check are reported in the specified error log. See Direct Loads, Integrity Constraints, and Triggers.
SQL*Loader tried to reenable the constraint but failed and thus:
The index will be left in an Index Unusable state if a violation of a UNIQUE constraint is detected. See Indexes Left in an Unusable State.
I'm pretty sure you will find that the primary key index is unusable (SELECT index_name, status FROM all_indexes WHERE table_name = 'PUR_ORDER').
Either load the datafile without direct path load or make sure that the constraint is successfully enabled afterwards.

Resources