Update statement with inner join on Oracle

That syntax isn’t valid in Oracle. You can do this: UPDATE table1 SET table1.value = (SELECT table2.CODE FROM table2 WHERE table1.value = table2.DESC) WHERE table1.UPDATETYPE=’blah’ AND EXISTS (SELECT table2.CODE FROM table2 WHERE table1.value = table2.DESC); Or you might be able to do this: UPDATE (SELECT table1.value as OLD, table2.CODE as NEW FROM table1 INNER JOIN … Read more

Table created in a procedure is dropped, Getting compilation error for procedure

Code which needs to check whether a table exists indicates bad software architecture. There should be no need to create tables on the fly. It’s an anti-pattern (at least in Oracle). However, we see variations on this problem often enough, so it’s obvious that this anti-pattern is thriving in the wild. If you really need … Read more

Oracle Sql Statement for unique timestamp for each row

The following UPDATE statement will guarantee that each row has a unique MY_TIMESTAMP value, by increasing the milliseconds by the rownum value. EDIT: After Alessandro Rossi pointed out that there could be duplicate values, the following query has been modified to use SYSTIMESTAMP for the update. UPDATE ITEM_HISTORY SET my_timestamp = SYSTIMESTAMP + NUMTODSINTERVAL(rownum/1000, ‘SECOND’); … Read more