VB and VBA Users Source Code: Oracle Tip: Performing and Update/Insert in a single line
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Oracle Tip: Performing and Update/Insert in a single line
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Monday, March 14, 2005
Hits:
1185
Category:
Database/SQL/ADO
Article:
In the example below, I want to insert the values, name=FullName and Age=30 into a test user table if the primary key (FullName) does not exist. If the primary key does exist, I just want to update column Age to 32. Here is the example: create table user_test (FullName varchar2(50) primary key, Age number); MERGE INTO user_test USING dual ON (dual.dummy IS NOT NULL AND user_test.FullName = 'Andrew') WHEN NOT matched THEN INSERT VALUES ('Andrew', 30) WHEN matched THEN UPDATE SET user_test.Age = 32;
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder