我有以下代码:
DECLARE v_oras locations.city%TYPE; BEGIN SELECT l.city FROM locations l,departments d WHERE l.location_id = d.location_id AND d.department_id = 30; END; /
如何将select分配给之前声明的变量?
使用SELECT INTO
声明.
DECLARE v_oras locations.city%TYPE; BEGIN SELECT l.city INTO v_oras FROM locations l JOIN departments d ON l.location_id = d.location_id WHERE d.department_id = 30; END;
这可以用于从SELECT
语句返回的多个值以及分配的INTO
声明变量.