论坛首页 入门技术论坛

关于在oracle中动态创建触发器问题,为什么有的机器可以创建成功呢

浏览 2738 次
该帖已经被评为新手帖
作者 正文
   发表时间:2007-10-24  
请教关于动态创建触发器问题,为什么我放在sqlplus中可以执行,把语句放到ibatis就不行了


//create sequence
allSQL.append("CREATE SEQUENCE USERTABLE_"+tableid+"_SEQ")
.append(" START WITH 1 ")
.append(" INCREMENT BY 1 ")
.append(" NOMINVALUE ")
.append(" NOMAXVALUE ")
.append(" NOCYCLE ")
.append(" CACHE 20 ")
.append(" ORDER \n commit;");
updateSql = allSQL.toString();
logger.debug("创建序列======="+updateSql);
allSQL.delete(0, allSQL.length());
updateObject("createTableSequenceTrigger", updateSql);

//create trigger
allSQL.append("CREATE OR REPLACE TRIGGER USERTABLE_"+tableid+"_SETID BEFORE\n");
allSQL.append("INSERT ON USERTABLE_").append(tableid).append(" FOR EACH ROW DECLARE\n");
allSQL.append(" next_id NUMBER;\n");
allSQL.append(" BEGIN\n");
allSQL.append(" SELECT USERTABLE_").append(tableid).append("_SEQ.NEXTVAL\n");
allSQL.append(" INTO next_id\n");
allSQL.append(" FROM dual;\n");
allSQL.append(" :new.ID := next_id;\n");
allSQL.append(" END;");
updateSql = allSQL.toString();
logger.debug("执行触发器创建======================="+updateSql);
allSQL.delete(0, allSQL.length());
updateObject("createTableSequenceTrigger", updateSql);



在IBATIS中的SQL语句为

<update id="createTableSequenceTrigger" parameterClass="string">
<![CDATA[
$updateSql$
]]>
</update>



报出错误为:
SqlMapClient operation; unca
tegorized SQLException for SQL []; SQL state [null]; error code [17041];
--- The error occurred in config/lzda/designer/sqlmap/designer.xml.
--- The error occurred while applying a parameter map.
--- Check the FORM_DESIGNER.createTableSequenceTrigger-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: 索引中丢失 IN 或 OUT 参数:: 1; nested excepti
on is com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in config/lzda/designer/sqlmap/designer.xml.
--- The error occurred while applying a parameter map.
--- Check the FORM_DESIGNER.createTableSequenceTrigger-InlineParameterMap.
--- Check the statement (update failed).

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics