sqlplus

Oracle: using substitution variables in sqlplus

Monday, March 17th, 2008

Get the value:

ACCEPT my_password CHAR PROMPT ‘Password:  ‘ HIDE
ACCEPT birthday DATE FORMAT ‘dd/mm/yyyy’ DEFAULT ‘01/01/1950′ PROMPT ‘Enter birthday date:  ‘

Declaring the variable

DEFINE the_answer = 42

Undefine the variable

UNDEFINE the_answer

How to remember the result of the query

COLUMN the_date new_value the_rundate noprint;
SELECT TO_CHAR(SYSDATE, ‘DDMMYYYY_HH24MI’) the_date FROM dual;
SELECT ‘&the_rundate’ FROM dual ;

Save the variables to the file

store SET myvars.txt [...]

Start sqlplus in Windows .BAT script

Monday, February 6th, 2006

Here is the example of emulating “HERE-documents” in Windows shell.
@ECHO OFF
FIND “/*%none% some_label”

Keep on coding