How do I write this?
DECLARE
STARTDATE DATE;
ENDDATE DATE;
BEGIN
STARTDATE='&&STRTDTE';
ENDDATE='&&ENDATE';
...
...
WHERE AAA_BBB.TR_DATE BETWEEN 'STARTDATE' AND 'ENDDATE';
How do I write this?
DECLARE
STARTDATE DATE;
ENDDATE DATE;
BEGIN
STARTDATE='&&STRTDTE';
ENDDATE='&&ENDATE';
...
...
WHERE AAA_BBB.TR_DATE BETWEEN 'STARTDATE' AND 'ENDDATE';
I'm guessing that you intend the script to prompt the user for the STRTDTE
and ENDATE
values (why "DTE" in one and "DATE" in the other, btw?).
Assuming that the user enters both dates in the current default format, then all you need is to change your where statement:
WHERE AAA_BBB.TR_DATE BETWEEN STARTDATE AND ENDDATE;
It might be safer, however, not to assume what the current format is, and actually prompt for the date in a specific format, then store the responses as dates using that specific format:
STARTDATE := TO_DATE( '&&STRTDTE', 'YYYY/MM/DD' );
ENDDATE := TO_DATE( '&&ENDATE', 'YYYY/MM/DD' );
or whatever format you wish.
Also note the :=
rather than =