I'm trying to do this:
select * from tab where date= to_date('&date_dd/mm/yyyy','dd/mm/yyyy');
but it asks 'date_dd' and not 'date_dd/mm/yyyy'.
How can I escape / character? I think that the problem is here!
You can't have this "/" in a variable's name, so it won't appear to the prompt as you do it. Use Lajos solution:
PROMPT Please enter the date with format dd/mm/yyyy:
select * from tab where date= to_date('&date','dd/mm/yyyy');
Will ask it so:
SQL> @my_script
Please enter the date with format dd/mm/yyyy:
Enter value for date:
You could also use ACCEPT e.g. following inspirations from e.g. Oracle SQL*Plus ACCEPT Statements
:
accept date PROMPT 'Please enter the date with format dd/mm/yyyy:'
select * from tab where date= to_date('&date','dd/mm/yyyy');
/? Are you able to answer my questions? What data are you trying to select from your table and what are you expecting the user to input?