0

この関数にinsertステートメントをパラメータとして渡し、関数内で実行して値を返したい場合はどうすればよいですか

create or replace function new_record (p_name your_table.first_name%type)
    return your_table.id%type
is
    return_value your_table.id%type;
begin
    begin
        insert into your_table (id, first_name)
            values (your_seq.nextval, p_first_name)
        returning id into return_value;
    exception
        when dup_val_on_index then
             return_value := 0;
    end;
    return return_value;
end;
4

1 に答える 1