Search results
11 lis 2015 · You could use the SQL%ROWCOUNT Oracle variable: UPDATE table1 SET field2 = value2, field3 = value3 WHERE field1 = value1; IF (SQL%ROWCOUNT = 0) THEN INSERT INTO table (field1, field2, field3) VALUES (value1, value2, value3); END IF;
19 lip 2022 · select m.last_refresh_time, s1.name, otherstat_1_value insert_count, s2.name, otherstat_2_value update_count, s3.name, otherstat_3_value delete_count from v$sql_plan_monitor m left join v$sql_monitor_statname s1 on m.otherstat_1_id = s1.id and s1.name like 'MERGE%' left join v$sql_monitor_statname s2 on m.otherstat_2_id = s2.id and s2.name like ...
11 cze 2020 · You issue a select statement to find if the record exists and then do an update if the record exists OR directly update and check with sql%rowcount if sql%rowcount <= 0 then raise exception... end if; there is no FK relationships or checks during update
5 gru 2019 · the exists just wastes time. the update will do the "read" and if it finds something -- the update, if not the insert will happen. this would be true in sqlserver as well!
4 kwi 2016 · When you are doing an existence check, then we only care if the query returns a row - we don't care what is *in* the row, just whether one comes back. select some_columns from my_table where exists ( select 1 from some_other_table )
19 mar 2012 · If exists update else insert. A frequent occurrence when writing database procedures is to handle a scenario where given a set of fields, for example a new employee record, update the existing employee record if it exists otherwise create it. Often this problem is solved with a select statement and then an IF statement, eg: declare.
1 - First try update, searching by the unique field (with returning into clause to get the primary key), if the key exists, it will works even if the update wasn't really needed, i.e, if the value updated is the same that the older.