0

This is my script. Trying to determine the best way to check if the row already exists by comparing the deptno

CREATE OR REPLACE PROCEDURE insert_rows
    (pl_deptno dept.deptno%TYPE, pl_dname dept.dname%TYPE, pl_loc dept.loc%TYPE
    ) AS
    BEGIN
    INSERT INTO dept 
    (deptno,dname,loc) 
    values ( pl_deptno,pl_dname,pl_loc);
    end insert_rows;
    /
4

1 回答 1

0

If deptno is a unique key, just insert a row. If there is a duplicate, catch the exception and do what is needed.

Otherwise, you get all kinds of race conditions that require transactions to handle if two users are inserting/checking at the same time.

于 2013-03-30T17:22:29.187 回答