How do I declare and use variables in Oracle?
Inside pl/sql block:

declare
 startdate number;
begin
  select 20110501 into startdate from dual;
end;
/


using a bind variable:

var startdate number;
begin
  select 20110501 into :startdate from dual;
end;
/


PL/SQL procedure successfully completed.

SQL&gt; print startdate

 STARTDATE
----------
  20110501


in a query:

select object_name 
from user_objects 
where created &gt; to_date (:startdate,'yyyymmdd');  /*prefix the bind variable wïth ":" */