oracle 游标简单案例
一.案例:
DECLARE
IDO NUMBER;
DABH VARCHAR2(50 CHAR);
t_count int(1);
CURSOR TJ_CURSOR IS SELECT IDO,DABH FROM ZLP_PERSONAL_INFO_115;
BEGIN
OPEN TJ_CURSOR;
LOOP
FETCH TJ_CURSOR INTO IDO,DABH;
SELECT count(*) into t_count FROM TJ_TJJL_115 t WHERE GRID=IDO;
IF t_count=0
THEN
DBMS_OUTPUT.PUT_LINE(IDO);
UPDATE ZLP_PERSONAL_INFO_115 SET HBSAG=3 where DABH=DABH;
ELSE
UPDATE ZLP_PERSONAL_INFO_115 SET HBSAG=(SELECT HBSAG FROM TJ_TJJL_115 WHERE GRID=IDO) WHERE DABH=DABH;
END IF;
END LOOP;
CLOSE TJ_CURSOR;
END;