ORACLE存储过程中游标 下面过程中输入参数APPLY_ID 我想让游标绑定结果集的SELECT语句中的APPLY_ID等于他
CREATEORREPLACEPROCEDUREAUTOAPPLY_MISSION(APPLY_IDINNUMBER,APPLY_NUMBERINNUMBER)ASV_C...
CREATE OR REPLACE PROCEDURE AUTOAPPLY_MISSION(APPLY_ID IN NUMBER,APPLY_NUMBER IN NUMBER) AS
V_COUNT NUMBER DEFAULT 0;
V_SEQ_PROCESSINFO NUMBER DEFAULT 0;
V_SEQ_PROCESSINFO_FLOWNUMBER NUMBER DEFAULT 0;
V_USERID NUMBER DEFAULT 0;
CURSOR CUR_USERID IS
SELECT T.APPLY_USER FROM APPLYINFO T WHERE T.APPLY_ID = C_APPLY_ID;
BEGIN
OPEN CUR_USERID;
LOOP
FETCH CUR_USERID
INTO V_USERID;
EXIT WHEN CUR_USERID(APPLY_ID)%NOTFOUND;
FOR VR IN (SELECT B.MEMBERID
FROM BASMEMBERINFO B
WHERE B.INCLUDED_TYPE IS NULL
AND ROWNUM < APPLY_NUMBER + 1) LOOP
UPDATE BASMEMBERINFO
SET INCLUDED_TYPE = '2'
WHERE MEMBERID = VR.MEMBERID;
SELECT SEQ_PROCESSINFO_ID.NEXTVAL INTO V_SEQ_PROCESSINFO FROM DUAL;
SELECT SEQ_PROCESSINFO_FLOWNUMBER.NEXTVAL
INTO V_SEQ_PROCESSINFO_FLOWNUMBER
FROM DUAL;
INSERT INTO PROCESSINFO
(PROCESS_ID, --??
-- PROCESS_USER_ID,--??ID --?
-- SOURCE_TYPE,--???? --0 ?
-- PROCESS_USER,--????? --?
PROCESS_DATE, --?????? --sysdate
PROCESS_USER_SOURCE, --????
PROCESS_TYPE, --???? --3 ???
-- PROCESSING_DATE,--???? ?
-- PROCESSING_USER,--??? ?
PROCESS_SEQ_ID, --???? ????????
-- NOTE,--?? ?
PROCESSING_PERSONNEL, --?????? ????
RECORD) --???? 2
VALUES
(V_SEQ_PROCESSINFO,
-- V_PROCESS_USER_SOURCE,
-- V_SOURCE_TYPE,
-- V_PROCESS_USER,
SYSDATE,
VR.MEMBERID,
'3',
-- V_PROCESSING_DATE,
-- V_PROCESSING_USER,
V_SEQ_PROCESSINFO_FLOWNUMBER,
-- V_NOTE,
V_USERID,'2'
);
END LOOP;
commit;
--END IF;
END LOOP;
CLOSE CUR_USERI;
END AUTOAPPLY_MISSION; 展开
V_COUNT NUMBER DEFAULT 0;
V_SEQ_PROCESSINFO NUMBER DEFAULT 0;
V_SEQ_PROCESSINFO_FLOWNUMBER NUMBER DEFAULT 0;
V_USERID NUMBER DEFAULT 0;
CURSOR CUR_USERID IS
SELECT T.APPLY_USER FROM APPLYINFO T WHERE T.APPLY_ID = C_APPLY_ID;
BEGIN
OPEN CUR_USERID;
LOOP
FETCH CUR_USERID
INTO V_USERID;
EXIT WHEN CUR_USERID(APPLY_ID)%NOTFOUND;
FOR VR IN (SELECT B.MEMBERID
FROM BASMEMBERINFO B
WHERE B.INCLUDED_TYPE IS NULL
AND ROWNUM < APPLY_NUMBER + 1) LOOP
UPDATE BASMEMBERINFO
SET INCLUDED_TYPE = '2'
WHERE MEMBERID = VR.MEMBERID;
SELECT SEQ_PROCESSINFO_ID.NEXTVAL INTO V_SEQ_PROCESSINFO FROM DUAL;
SELECT SEQ_PROCESSINFO_FLOWNUMBER.NEXTVAL
INTO V_SEQ_PROCESSINFO_FLOWNUMBER
FROM DUAL;
INSERT INTO PROCESSINFO
(PROCESS_ID, --??
-- PROCESS_USER_ID,--??ID --?
-- SOURCE_TYPE,--???? --0 ?
-- PROCESS_USER,--????? --?
PROCESS_DATE, --?????? --sysdate
PROCESS_USER_SOURCE, --????
PROCESS_TYPE, --???? --3 ???
-- PROCESSING_DATE,--???? ?
-- PROCESSING_USER,--??? ?
PROCESS_SEQ_ID, --???? ????????
-- NOTE,--?? ?
PROCESSING_PERSONNEL, --?????? ????
RECORD) --???? 2
VALUES
(V_SEQ_PROCESSINFO,
-- V_PROCESS_USER_SOURCE,
-- V_SOURCE_TYPE,
-- V_PROCESS_USER,
SYSDATE,
VR.MEMBERID,
'3',
-- V_PROCESSING_DATE,
-- V_PROCESSING_USER,
V_SEQ_PROCESSINFO_FLOWNUMBER,
-- V_NOTE,
V_USERID,'2'
);
END LOOP;
commit;
--END IF;
END LOOP;
CLOSE CUR_USERI;
END AUTOAPPLY_MISSION; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询