Skip to content

Hongyu's weblog

Science, Technology, and Beyond

Day: February 3, 2009

Posted on February 3, 2009February 3, 2009

Avoid inserting duplicated records in Oracle

See http://www.techonthenet.com/sql/insert.php

INSERT INTO clients
(client_id, client_name, client_type)
SELECT 10345, ‘IBM’, ‘advertising’
FROM dual
WHERE not exists (select * from clients
where clients.client_id = 10345);

The use of the dual table allows you to enter your values in a select statement, even though the values are not currently stored in a table.

Archives

February 2009
M T W T F S S
 1
2345678
9101112131415
16171819202122
232425262728  
« Dec   Jul »
Proudly powered by WordPress