在Oracle中,可以通過以下方法給游標變量賦值:
DECLARE
CURSOR cursor_name IS
SELECT column1, column2
FROM table_name
WHERE condition;
variable1 table_name.column1%TYPE;
variable2 table_name.column2%TYPE;
BEGIN
OPEN cursor_name;
FETCH cursor_name INTO variable1, variable2;
CLOSE cursor_name;
-- 此時 variable1 和 variable2 就是游標的值
END;
DECLARE
CURSOR cursor_name IS
SELECT column1, column2
FROM table_name
WHERE condition;
variable1 table_name.column1%TYPE;
variable2 table_name.column2%TYPE;
BEGIN
FOR cursor_row IN cursor_name
LOOP
variable1 := cursor_row.column1;
variable2 := cursor_row.column2;
-- 在這里可以使用 variable1 和 variable2
END LOOP;
END;
以上是常用的幾種給Oracle游標賦值的方法。具體使用哪種方法取決于具體情況和個人偏好。