Anyone know what is wrong with this code?
I cannot figure why Oracle 8i is giving me this error: "ORA-01008: not all variables bound". Help please.
Code:
DECLARE
v_deptexclude VARCHAR2(30) := 'Direct Retail Lending%';
v_queuetype VARCHAR2(10) := 'new';
v_catgnew VARCHAR2(10) := 'NEW';
v_catgbacklog VARCHAR2(10) := 'BACKLOG';
v_stepname1 VARCHAR2(10) := 'Complete';
v_stepname2 VARCHAR2(10) := '%QA%';
sql_stmt VARCHAR2(2000);
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE LSAPP_WORKFLOWSTATUS';
-- Summarize the data.
sql_stmt := 'INSERT INTO LSAPP_WORKFLOWSTATUS SELECT DEPARTMENT, DEPTINITIAL, SUM(CASE WHEN CATG = :4 THEN 1 ELSE 0 END) AS WOB_BACKLOG, SUM(CASE WHEN CATG = :4 AND CREATETIME < TRUNC(SYSDATE-7) THEN 1 ELSE 0 END) AS OLD_BACKLOG, ROUND(CASE WHEN SUM(CASE WHEN CATG = :4 THEN 1 ELSE 0 END) = 0 THEN 0 ELSE SUM(CASE WHEN CATG = :4 AND CREATETIME < TRUNC(SYSDATE-7) THEN 1 ELSE 0 END) / SUM(CASE WHEN CATG = :4 THEN 1 ELSE 0 END) END, 6) AS OLD_BACKLOG_PCT, SUM(CASE WHEN CATG = :4 AND EXISTS (SELECT * FROM REPORTLS.RETAIL_PROCESSLOG C WHERE C.WOBNUM = F_WOBNUM AND (C.STEPNAME = :5 OR C.STEPNAME LIKE :6)) THEN 1 ELSE 0 END) AS WOB_BACKLOG_COMPLETE,SUM(CASE WHEN CATG = :3 THEN 1 ELSE 0 END) AS WOB_NEW, SUM(CASE WHEN CATG = :3 AND EXISTS (SELECT * FROM REPORTLS.RETAIL_PROCESSLOG C WHERE C.WOBNUM = F_WOBNUM AND (C.STEPNAME = :5 OR C.STEPNAME LIKE :6)) THEN 1 ELSE 0 END) AS WOB_NEW_COMPLETE, ROUND(CASE WHEN SUM(CASE WHEN CATG = :3 THEN 1 ELSE 0 END) = 0 THEN 0 ELSE SUM(CASE WHEN CATG = :3 AND EXISTS (SELECT * FROM REPORTLS.RETAIL_PROCESSLOG C WHERE C.WOBNUM = F_WOBNUM AND (C.STEPNAME = :5 OR C.STEPNAME LIKE :6)) THEN 1 ELSE 0 END) / SUM(CASE WHEN CATG = :3 THEN 1 ELSE 0 END) END, 6) AS NEW_COMPLETE_PCT, SYSDATE AS LASTUPDATE FROM (SELECT WOBNUM AS F_WOBNUM, DEPARTMENT, DEPTINITIAL, :4 AS CATG, CREATETIME FROM LS_WOBBACKLOG A, REPORTLS.WORKTYPES B WHERE A.WORKTYPE = B.WORKTYPE AND ENQUEUETIME < TRUNC(SYSDATE-1)+17/24 UNION ALL SELECT WOBNUM AS F_WOBNUM, DEPARTMENT, DEPTINITIAL, :3 AS CATG, STARTTIME FROM REPORTLS.RETAIL_PROCESSLOG A, REPORTLS.WORKTYPES B WHERE A.WORKTYPE = B.WORKTYPE AND ENQUEUETIME >= TRUNC(SYSDATE-1)+17/24 AND ENQUEUETIME < TRUNC(SYSDATE)+17/24 AND DEPARTMENT NOT LIKE :1 AND USERID NOT IN (SELECT P8USERID FROM REPORTLS.BGPERFORMERS) AND STEPNAME IN (SELECT STEPNAME FROM REPORTLS.LSAPP_STEPNAME WHERE QUEUETYPE = :2)) GROUP BY DEPARTMENT, DEPTINITIAL';
EXECUTE IMMEDIATE sql_stmt USING v_deptexclude, v_queuetype, v_catgnew, v_catgbacklog, v_stepname1, v_stepname2;
-- Save the changes.
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK; -- rollback the transaction
END;
I cannot figure why Oracle 8i is giving me this error: "ORA-01008: not all variables bound". Help please.