IF Chzonecode IS NOT NULL THEN OPEN B1 FOR SELECT user_id, user_code, user_name, electric_power_ct, elec_number, zone_code FROM be_user t WHERE t.zone_code = Chzonecode AND t.user_type IN ('0', '1', '8', '15');ELSE OPEN B1 FOR SELECT user_id, user_code, user_name, electric_power_ct, elec_number, zone_code FROM be_user t WHERE t.user_type IN ('0', '1', '8', '15');END IF;FETCH B1 INTO B;WHILE B1%FOUND LOOP -- do something with B FETCH B1 INTO B;END LOOP;CLOSE B1; 这样会报错请声明B1,请重新修改一下
时间: 2023-06-15 11:08:09 浏览: 84
PHP ignore_user_abort函数详细介绍和使用实例
好的,修改如下:
DECLARE
B1 SYS_REFCURSOR;
B be_user%ROWTYPE;
BEGIN
IF Chzonecode IS NOT NULL THEN
OPEN B1 FOR
SELECT user_id, user_code, user_name, electric_power_ct, elec_number, zone_code
FROM be_user t
WHERE t.zone_code = Chzonecode AND t.user_type IN ('0', '1', '8', '15');
ELSE
OPEN B1 FOR
SELECT user_id, user_code, user_name, electric_power_ct, elec_number, zone_code
FROM be_user t
WHERE t.user_type IN ('0', '1', '8', '15');
END IF;
FETCH B1 INTO B;
WHILE B1%FOUND LOOP
-- do something with B
FETCH B1 INTO B;
END LOOP;
CLOSE B1;
END;
阅读全文