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 · update customers_dim cd set ( full_name, update_datetime ) = ( select cs.full_name, systimestamp from customers_stage cs where cs.customer_id = cd.customer_id ) where exists ( select null from customers_stage ce where ce.customer_id = cd.customer_id )
29 kwi 2015 · IF EXISTS (select * from users where username = 'something') THEN. update users set id= 'some' where username = 'something'; ELSE. insert into users (username) values ('something'); END IF; end $$. delimiter ; and call it like this: call select_or_insert();
5 gru 2019 · In the dialect for procedural SQL in MSSQL and Sybase, there's a useful little idiom for checking whether rows exist on a table, and it looks like this... if exists (select 'x' from foo where bar) /* found, do something */ else /* not found, do something else */
This statement is equivalent to: update people_target t set (t.first_name, t.last_name) = ( select s.first_name, s.last_name from people_source s where s.person_id = t.person_id ) where exists ( select null from people_source s where s.person_id = t.person_id).
17 paź 2024 · The MERGE statement in SQL can insert a new record into a table or update the existing record if it already exists. It is supported by databases like Oracle, SQL Server, and PostgreSQL. Let’s look at how we can use the MERGE statement: MERGE INTO Department AS target.
11 cze 2020 · 1. I have several PL/SQL procedures that use several update statments. After each update, I use the. IF (sql%rowcount > 0) THEN. update 2nd table. END IF; and so on. I am doing a lot of IFs and I am wondering whether I cao commit all updates at once or rollback. If updates results in 0 rows updated would it raise any excpetion?