mybatis oracle proc 数据库测试没问题,java调用就异常 ORA-00900: 无效 SQL 语句
程序员文章站
2023-03-07 23:47:13
测试存储过程,输入输出,打印declarenumbers number;begindoc_serial_number_proc('77',numbers);DBMS_OUTPUT.PUT_LINE(numbers);end;编写存储过程CREATE OR REPLACEprocedure doc_serial_number_proc( acset_code_ym in varchar2,-- 输入 FYDRG+账套号+年月(如1907) numbers out number -...
测试存储过程,输入输出,打印
declare
numbers number;
begin
doc_serial_number_proc('77',numbers);
DBMS_OUTPUT.PUT_LINE(numbers);
end;
编写存储过程
CREATE OR REPLACE
procedure doc_serial_number_proc(
acset_code_ym in varchar2,-- 输入 FYDRG+账套号+年月(如1907)
numbers out number --流水号 10001
)as
v_name varchar2(20);
ids number; -- id;
current_values number ;
begin
SELECT id,current_value into ids ,numbers FROM EDOC_DOC_SERIAL_NUMBER WHERE code_ym_number =acset_code_ym;
--
-- if numbers is not null then
-- numbers:=10001;
-- insert into EDOC_DOC_SERIAL_NUMBER(code_ym_number,current_value) values(1,2);
--
-- elsif numbers is null then
--
-- numbers:=numbers+1;
-- update EDOC_DOC_SERIAL_NUMBER set current_value = 6 where id = ids;
--
-- end if;
EXCEPTION
WHEN NO_DATA_FOUND THEN
dbms_output.put_line('没有查到数据');
end;
<!-- 调用存储过程 -->
<select id="callDoc" statementType="CALLABLE" parameterType="java.util.Map" resultType="java.lang.Integer">
<![CDATA[
{call doc_proc(#{acset_code,mode=IN,jdbcType=VARCHAR},#{num,mode=INOUT,jdbcType=INTEGER})}
]]>
</select>
************************************************************************
==mabatis ==
<select id="callNumber" statementType="CALLABLE" parameterType="java.util.Map" resultType="java.lang.String">
call doc_number_proc(#{acsetCodeYm,mode=IN,jdbcType=VARCHAR},#{serials,mode=OUT,jdbcType=VARCHAR})
</select>
最终结果如下 输入 输出参数
oracle
CREATE OR REPLACE
procedure doc_number_proc(
acsetCodeYm in varchar2,
serials out varchar2
)is
ids number;
current_values number ;
vcount number;
versions number ;
begin
SELECT count(1) into vcount FROM EDOC_DOC_SERIAL_NUMBER WHERE code_ym_number =acsetCodeYm and DELETED=0;
if vcount=0 then
dbms_output.put_line('2查到数据'||ids||'=='||current_values);
current_values:=10001;
insert into EDOC_NUMBER(id,code_ym_number,current_value,CREATE_TIME,LAST_MODIFY_TIME,DELETED,VERSION)
values(doc_serial_number_seq.NEXTVAL,acsetCodeYm,current_values,sysdate,sysdate,0,1);
elsif vcount=1 then
SELECT id,current_value,VERSION into ids ,current_values,versions FROM EDOC_NUMBER WHERE code_ym_number =acsetCodeYm and DELETED=0;
versions:=versions+1;
dbms_output.put_line('3查到数据'||ids||'=='||current_values);
current_values:=current_values+1;
update EDOC_NUMBER set current_value =current_values,LAST_MODIFY_TIME=sysdate,version=versions where id = ids;
end if;
serials:=current_values;
end;
结果:**在传值,取值,不要有特殊字符,名称;如num,number,等,尽量区分开**
本文地址:https://blog.csdn.net/xiaoja_save/article/details/107317157