java建立觸發器失敗(Missing IN or OUT parameter at index:: 1 )
阿新 • • 發佈:2019-02-02
觸發器程式碼如下:
create or replace trigger trigger_33zOtisNB5cZ_LMAhwtmDg before insert or update of STUNAME on T_STU for each row begin if inserting then insert into table_33zOtisNB5cZ_LMAhwtmDg values ('insert',sysdate,:new.STUID); elsif updating then insert into table_33zOtisNB5cZ_LMAhwtmDg values ('update',sysdate,:new.STUID); elsif deleting then insert into table_33zOtisNB5cZ_LMAhwtmDg values ('delete',sysdate,:old.STUID); end if;end;
java執行程式碼:
PreparedStatement state = conn.prepareCall(sql);
state.execute();
執行時出錯,猜測原因:執行的時候將上述語句翻譯成了帶引數的查詢,如果把建立觸發器語句中的:new,:old等關鍵字去掉則執行成功
解決方案:
Statement state = conn.createStatement();
state.execute(sql);
問題解決!