1、当SELECT语句未找到记录时,会出现异常。你可以使用异常处理。
如:
select SequenceID into v_SequenceID from PrePayment where ID=i_ID;
exception
when no_data_found then
v_sequenceid := 0; --(或其他处理语句)
2、不知道你数据库的nls_date_format是如何设置的?
不过最好使用to_char(sysdate,'yyyy-mm-dd')
如:
select SequenceID into v_SequenceID from PrePayment where ID=i_ID;
exception
when no_data_found then
v_sequenceid := 0; --(或其他处理语句)
2、不知道你数据库的nls_date_format是如何设置的?
不过最好使用to_char(sysdate,'yyyy-mm-dd')
第二个问题:不是第一个字段PeriodID的值substr(to_char(sysdate),1,6)的原因造成的,主要是SequenceID的值LSH_FUNC_GetAgentPrePaymentSeq('2',substr(to_char(sysdate),1,6))造成的,我测试过了,不知道在insert的时候,能否调用自己的函数?
select count(*) from PrePayment where ID=i_ID
先判断记录数是否为0
sql>begin
select count(*) into :countnum form t where clause;
if :countnum=1 then
...........
if .... then
应该可以的