|
发表于 2020-2-1 00:54:01
|
显示全部楼层
刚才的Procedure有问题,现已做如下改动!
----For Oracle!
Create or Replace Procedure ListSequence(V_EMPNO IN NUMBER) as
V_SQL VARCHAR2(200);
V_DELETE_SEATNO NUMBER:=0;
V_TEMP_INDEX NUMBER:=0;
TYPE REFCUR IS REF CURSOR;
C_T1 REFCUR;
CURSOR C1 IS
SELECT * FROM TABLE_NAME;
C1_DATA C1%ROWTYPE;
BEGIN
V_SQL:='SELECT SEATNO FROM TABLE_NAME WHERE EMPNO='||V_EMPNO;
EXECUTE IMMEDIATE V_SQL INTO V_DELETE_SEATNO;
EXECUTE IMMEDIATE 'DELETE FROM TABLE_NAME WHERE EMPNO='||V_EMPNO;
COMMIT;
OPEN C1;
LOOP
FETCH C1 INTO C1_DATA;
EXIT WHEN C1%NOTFOUND;
IF C1_DATA.SEATNO > V_DELETE_SEATNO THEN
IF C1_DATA.STATUS1<>'N' THEN
V_TEMP_INDEX:=C1_DATA.SEATNO;
V_SQL:='UPDATE TABLE_NAME SET SEATNO='||V_DELETE_SEATNO||' WHERE SEATNO='||C1_DATA.SEATNO;
EXECUTE IMMEDIATE V_SQL;
COMMIT;
V_DELETE_SEATNO:=V_TEMP_INDEX;
END IF;
END IF;
END; |
|