Om du vill definiera en lokal variabel i PL/SQL behöver du ett komplett PL/SQL-block
DECLARE
id NUMBER;
BEGIN
SELECT 1000
INTO id
FROM dual;
END;
eller bara
DECLARE
id NUMBER := 1000;
BEGIN
<<do something that uses the local variable>>
END;
Om du vill deklarera en variabel i SQL*Plus
SQL> variable id number
SQL> begin
select 1000 into :id from dual;
end;
/
SQL> print id
ID
----------
1000
SQL> SELECT * FROM tbl_a WHERE id = :id