我尝试编写一个存储过程,以使事务号每天返回到01,但是当我运行它时,当天到01的所有事务号都不会增加。
然后我添加
and (V_JML_RECORD = 1) THEN
V_JML_RECORD: = V_JML_RECORD +1;
当我运行它时,出现ORA-01422
错误;所请求的行数是否有确切的准确回报,可以解释并为我的问题提供解决方案?
SELECT TRIM (NAMA), TRIM (KD_KTR) AS KDKTR
INTO V_NAMA, V_KDKTR
FROM D_PRS
WHERE TRIM (STB) = P_STB;
SELECT TO_CHAR (sysdate, 'MM')
INTO V_BLNSKR
from dual;
SELECT TO_CHAR (sysdate, 'DD')
INTO V_HRSKR
from dual;
SELECT COUNT(NOKAS)
INTO V_JML_RECORD
FROM (
SELECT NOKAS,TGKAS,KTRASL FROM D_MSTHEADER_UKERJA WHERE TGKAS IN(
SELECT MAX(TGKAS) FROM D_MSTHEADER_UKERJA WHERE KTRASL=V_KDKTR)
)
IF (V_BLNSKR = '02')
AND (V_HRSKR = '27') THEN
V_JML_RECORD := 1;
ELSIF (V_BLNSKR = '02')
AND (V_HRSKR = '27')
AND (V_JML_RECORD = 1) THEN
V_JML_RECORD := V_JML_RECORD +1;
ELSE
V_JML_RECORD := V_JML_RECORD +1;
END IF;
答案 0 :(得分:0)
要立即解决您的问题,请在下面的查询中添加ROWNUM = 1,但是正确的方法是让您通过检查原始查询的结果来检查哪一行是正确的行。使用INTO函数时,只需要获取一个单行查询即可。
SELECT TRIM (NAMA), TRIM (KD_KTR) AS KDKTR
INTO V_NAMA, V_KDKTR
FROM D_PRS
WHERE TRIM (STB) = P_STB AND ROWNM = 1;