If data exists then update it, otherwise insert it.
In Oracle/PLSQL
BEGIN
UPDATE TABLE_NAME SET COL='a' WHERE ID='foobar';
IF sql%rowcount = 0 THEN
INSERT INTO TABLE_NAME (ID,COL) VALUES('foobar','a');
END IF;
END;
My Learning note
If data exists then update it, otherwise insert it.
In Oracle/PLSQL
BEGIN
UPDATE TABLE_NAME SET COL='a' WHERE ID='foobar';
IF sql%rowcount = 0 THEN
INSERT INTO TABLE_NAME (ID,COL) VALUES('foobar','a');
END IF;
END;
沒有留言:
張貼留言