Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Variable puzzle, cannot use a variable in a where clause

Variable puzzle, cannot use a variable in a where clause

From: Phil <p.cand_at_onsemi.com>
Date: 5 Jan 2005 13:01:31 -0800
Message-ID: <1104958891.500952.244780@f14g2000cwb.googlegroups.com>


Hi,
I try to do something like select x from y where z = variable. I cannot get it to work and could not find any example or info.

As an example the code bellow works as far as setting the variable value is concerned however it returns an error. ORA-06550: line 11, column 1:
PLS-00428: an INTO clause is expected in this SELECT statement. When I try to use the variable in a select clause. Thanks,
Phil

Declare my_Date number(6);
begin
select
TO_NUMBER(TO_CHAR(ADD_MONTHS(TO_DATE(TO_CHAR(a.fiscal_yyyymm_num), 'YYYYMM'), 3),'YYYYMM'))
Into my_Date
FROM dataware.fiscal_calendar a
WHERE a.query_dt = TRUNC(sysdate);

--dbms_output.put_line (my_Date);

Select * from dataware.Orders o where o.ShipSchedule_yyyymm_num = my_Date;

end; Received on Wed Jan 05 2005 - 15:01:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US