云数据库 GaussDB-隐式游标:示例

时间:2025-02-12 15:06:00

示例

 1 2 3 4 5 6 7 8 9101112131415161718192021222324252627
--删除EMP表中某部门的所有员工,如果该部门中已没有员工,则在DEPT表中删除该部门。CREATE TABLE hr.staffs_t1 AS TABLE hr.staffs;CREATE TABLE hr.sections_t1 AS TABLE hr.sections;CREATE OR REPLACE PROCEDURE proc_cursor3() AS     DECLARE    V_DEPTNO NUMBER(4) := 100;    BEGIN        DELETE FROM hr.staffs WHERE section_ID = V_DEPTNO;        --根据游标状态做进一步处理        IF SQL%NOTFOUND THEN        DELETE FROM hr.sections_t1 WHERE section_ID = V_DEPTNO;        END IF;    END;/CALL proc_cursor3(); proc_cursor3 --------------(1 row)--删除存储过程和临时表DROP PROCEDURE proc_cursor3;DROP TABLE hr.staffs_t1;DROP TABLE hr.sections_t1;
support.huaweicloud.com/distributed-devg-v3-gaussdb/gaussdb-12-0742.html