How can find deleted row in a table using ORA_ROWSCN function - oracle

How can we find a row which is deleted in Oracle table with help of ORA_ROWSCN. If a row is deleted we get new ORA_ROWSCN. But how to know this is a deleted one.

Related

ORA-08006: specified row no longer exists

i have delete some duplicates in table which is paritioned using LIST for status Y and N. I have deleted duplicates which are active
delete from my_table partition(active_flag_y) where rowid = ( duplicate logic )
Post delete i started running my Informatica mapping which is having Update + insert logic.
While updating it is giving me
ORA-08006: specified row no longer exists
I am deleting using rowid but that rowid exists in my table.
Can someone help me with the solution
While updating it is giving me ORA-08006: specified row no longer exists
Include additional condition to update:
update your_table a
set ...
-- add this:
where exists (select null
from table_from_which_you_deleted_rows b
where b.rowid = a.rowid
);
Next question is: what will you do with rows in YOUR_TABLE whose ROWID doesn't exist in a table you're referencing?
As you noticed, ROWID isn't the best piece of information you can rely on. Documentation says:
If you delete and reinsert a row with the Import and Export utilities, for example, then its rowid may change. If you delete a row, then Oracle may reassign its rowid to a new row inserted later.

Update on any child table's row is locking entire parent table in oracle

I have a parent table PT having below columns
PT_ID,
PT1_ID,
PT2_ID,
PT_COMMENT
Another child table CT is there having below columns
CT_ID,
PT_ID,
PT1_ID,
PT2_ID,
CT_COMMENT
There are rows in CT table where foreign key columns are having null values (means no value)
If we are updating the CT_COMMENT in CT table for more than 320 rows and at the same time in another seesion we are trying to update one parent table comment in PT_COMMENT column which is not happening until child records update is not getting completed.
Here same Parent table PT_ID row is not getting updated in child table CT, Though Parent Table is getting stuck.
Can anyone help me out to figure it out the reason for locking?
Thank in advance
The index was not appropriate, hence the parent table was getting locked.
After the recreation of an index, now it is working.

Redirect duplicate rows to update while insert

I have a insert statement on table "test". PK on column x in the table "test".
Now while inserting if duplicate row comes then the same row should get updated instead insert.
How can i achieve this.
Is it possible by dup_val_on_index?
Please help.
First create a copy of the above table without any KEY Columns and follow
Step 1: truncate the table first whenever you encounter a bunch of insert statement comes
Step 2: INSERT the above truncated tables
Step 3: Execute the MERGE statement like below
MERGE INTO TABLE_MAIN M
USING TABLE_MAIN_COPY C
ON (m.id = c.id)
WHEN MATCHED THEN UPDATE SET M.somecol = c.somecol
WHEN NOT MATCHED THEN INSERT (m.id, m.somecol)
VALUES (c.id, c.somecol);
You may incur error while on merger ORA-30926: unable to get a stable set of rows in the source tables when there is two or more rows while on update.
you may avoid that using the GROUP function related to id or like ORA-30926: unable to get a stable set of rows in the source tables

Issue in Oracle Insert while Drop index and create after insert records

In oracle i did a insert in to big table contain more than million record.Before insert i drop a index on the table and insert it for a better performance and after insert i create a index for the table .But here is the issue,While creating index on table its shows me Unique constraint error,because it is vioating one of my unique index.Please advice how to proceed furthur.Since i dropped index and insert i am not able to check index while inserting records into table.
Thanks
venkat
The solution would be remove the new offending row and create the index again.You'd be better off if you don't try to insert that row in database.

viable to perform oracle table rollback by using rowid?

i am performing oracle table rollback using rowId:
so before each data injection, i record the max rowid of the table.
If anything went wrong, i will delete from table where rowid > max rowid recorded.
after deletion is executed, i can still see injected records.
please advice!
thanks,
Richard
A ROWID is :
A globally unique address for a row in a database.
It is not an identifier that will be incremented for each new row. A new row could use a previously used ROWID if the row that had this ROWID has been deleted.
Also note that Oracle could reuse an older block that has been freed for new rows (which would result in a lower ROWID). Oracle could also get extents in another data file with a lower file number than the file of the last ROWID. In most cases you can't control precisely where your new rows will end up physically so you should not rely on ROWID increasing.
Finally you shouldn't depend upon the current implementation of ROWID, it could change in future releases.
You could use a sequence or a timestamp column to identify new records. Or even a flag column.

Resources