I am new to Oracle (though familiar with SQL) and have to write a fairly complex query where a value derived from the current date is used many times. Rather than calculate the value each time, it would seem obvious to declare a constant for the purpose.
However, when I then try to use my DateIndex constant in the subsequent SELECT statement (which I wish to return values based on "DateIndex"), the parser tells me that it is exepcting SELECT INTO.
What I have (simplified to the lowest form) is...
DECLARE DateIndex CONSTANT NUMBER(10,0) := 24;
BEGIN
SELECT DateIndex
FROM DUAL;
END;
Is it only possible to use constants when selecting into a table rather than returning results? Seems very odd.
Note that I do not have write permissions on the database.
Many thanks for any assistance.