Hvis du vil definere en lokal variabel i PL/SQL, skal du bruge en komplet PL/SQL-blok
DECLARE
id NUMBER;
BEGIN
SELECT 1000
INTO id
FROM dual;
END;
eller bare
DECLARE
id NUMBER := 1000;
BEGIN
<<do something that uses the local variable>>
END;
Hvis du ønsker at erklære 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