Click to See Complete Forum and Search --> : Using sysdate as default in PROMPT and ACCEPT


mjjrr1
02-24-2003, 11:07 AM
Hi I am running the following SQL script in sqlPlus

ACCEPT g_TXN_Date date format 'dd/mm/yyyy' PROMPT 'Enter Start Date (leave blank FOR today): ' default sysdate

select TO_CHAR(TO_DATE('&g_TXN_Date'), 'DD/MM/YYYY') from dual
/

The idea is the user can only specify a date but if they don't specify anything then the current date is selected.

I get errors

Enter value for g_txn_date:
old 1: select TO_CHAR(TO_DATE(&g_TXN_Date), 'DD/MM/YYYY') from dual
new 1: select TO_CHAR(TO_DATE(), 'DD/MM/YYYY') from dual
select TO_CHAR(TO_DATE(), 'DD/MM/YYYY') from dual
*
ERROR at line 1:
ORA-00938: not enough arguments for function

Any help would be great !

jovery
02-24-2003, 11:18 AM
You'll need to do something similar to the following:

COLUMN date1 new_value curdate NOPRINT
SELECT sysdate date1 FROM dual;
ACCEPT g_TXN_Date DATE FORMAT 'dd/mm/yyyy'
DEFAULT '&curdate'
PROMPT 'Enter the date (DD/MM/YYYY): '


Regards