1 Replies - 2355 Views - Last Post: 31 July 2012 - 07:36 PM

#1 ItIntern3  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 97
  • Joined: 14-July 10

Declaring Variables in PLSQL

Posted 09 July 2012 - 05:53 AM

Hi all,

I am very new to Oracle and PLSQL and am having trouble declaring and using variables within a basic query. I have looked at several different sites and seem to get an error on every syntatic change I make. I entered the following in a sql editor within Toad for oracle:

BEGIN
	start_date DATE :=to_date('01-01-1999', 'MM-DD-YYYY');
	end_date DATE :=to_date('12-31-2012', 'MM-DD-YYYY');
	
	select *
	from mlt_data melt
	where melt.act_mlt_strt_dtime >= start_date
	and melt.act_mlt_end_dtime <= end_date

END;



I am receiving the following errors:
ORA-06550: line 2, column 13:
PLS-00103: Encountered the symbol "DATE" when expecting one of the following:

:= . ( @ % ;
The symbol "." was substituted for "DATE" to continue.
ORA-06550: line 3, column 11:
PLS-00103: Encountered the symbol "DATE" when expecting one of the following:

:= . ( @ % ;
The symbol "." was substituted for "DATE" to continue.
ORA-06550: line 10, column 1:
PLS-00103: Encountered the symbol "END" when expecting one of the following:

. ( * @ % & - + ; / at for mod remainder


Any help would be much appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Declaring Variables in PLSQL

#2 idunno  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 10-October 11

Re: Declaring Variables in PLSQL

Posted 31 July 2012 - 07:36 PM

Hi
DECLARE
start_date DATE;
end_date DATE;
BEGIN
    start_date :=to_date('01-01-1999', 'MM-DD-YYYY');
    end_date :=to_date('12-31-2012', 'MM-DD-YYYY');



idunno what you are trying to do but
your select statemet should be a cursor otherwise add into(SELECT col1 INTO)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1