How do I declare and use variables in Oracle? My main skills are with SQL Server, but I have been asked to do some tuning of an Oracle query. I have written the following SQL:

declare @startDate int
select @startDate = 20110501


And I get this error:

declare @startDate int
select @startDate = 20110501
Error at line 1
ORA-06550: line 1, column 9:
PLS-00103: Encountered the symbol "@" when expecting one of the following:

   begin function package pragma procedure subtype type use
   &lt;an identifier&gt; &lt;a double-quoted delimited-identifier&gt; form
   current cursor


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 ":" */