5 Replies Latest reply on Jun 24, 2008 1:28 PM by 646475

    Declare constant or variables in a SQL statement and use in a query

    646747
      Hi,
      I'd like to use a constant in a query oracle. (with sql-developer)
      I want to declare this constant (ex a date) only one time in the statement and then I want use that constant in the "where" part of the query.

      I tried this for example:
      DECLARE
      prova CONSTANT VARCHAR(8) := '20080601';
      BEGIN
      SELECT * FROM WN_T_CON_PREST PREST2 WHERE PREST2.D_CON_DATA_FINE>=TO_DATE(prova,'YYYYMMDD');
      END;

      I selected the query, I played the query (F9 in sql-developer), but it doesn't work.

      There is anyone who can help me?