---用意:首先插入数据,然后执行 commit 。接着检查数据是否存在,如果不存在 报错 NO_DATA_FOUND,重复执行该操作 。如果存在 抽取最大的 rownu 赋值 V_PID,然后输出 V_PID
create or replace procedure BATCH_INSERT_TABLEA_BOOK_MAIN(BK_ISBN IN Varchar2,
bk_name IN nVarchar2,
bk_author IN nVarchar2,
bk_rcmd IN NUMBER,
bk_type IN NUMBER,
bk_typelist IN Varchar2,
bk_keyword IN nVarchar2,
bk_remark IN nVarchar2,
bk_userid IN NUMBER,
bk_publishtime DATE ,
bk_press IN nVarchar2,
bk_tree IN clob,
bk_status IN Number,
bk_img IN nVarchar2,
bk_price IN number ,
bk_star IN number,
br_counts IN number, RESULTBKID OUT NUMBER) is
V_PID number;
V_CurrentBkid number;
V_COUNT NUMBER;
begin
SELECT MAX(bk_id) INTO V_PID FROM BOOK_MAIN;
DBMS_OUTPUT.PUT_LINE(V_PID);
--获取该表中最大的bk_id
--开始插入数据
V_CurrentBkid := BOOK_MAIN_SEQ.NEXTVAL;
INSERT INTO BOOK_MAIN VALUES(V_CurrentBkid,
BK_ISBN,
bk_name,
bk_author,
bk_rcmd,
bk_type,
bk_typelist,
bk_keyword,
bk_remark,
bk_userid,
sysdate,
bk_publishtime,
bk_press,
bk_tree,
bk_status,
bk_img,
bk_price,
bk_star,
br_counts);
V_COUNT :=SQL%ROWCOUNT;
DBMS_OUTPUT.PUT_LINE( ‘v_count is ‘||V_COUNT);
COMMIT;
IF SQL%ROWCOUNT=0 then
DBMS_OUTPUT.put_line(‘ERROR‘);
END IF;
SELECT MAX(bk_id) INTO V_PID FROM BOOK_MAIN;
DBMS_OUTPUT.put_line(V_PID); --输出当前 最大的 bk_id
--判断是否插入成功
RESULTBKID := V_CurrentBkid;--返回主键id
dbms_output.put_line(V_CurrentBkid);
END BATCH_INSERT_TABLEA_BOOK_MAIN;