Is there a way to set default value of paramter in sqlplus script without user input?
For example, I have an SQL script sessions.sql:
SET VERIFY OFF SET TERMO
For those who don't fancy chasing and perusing links that can go away anytime, here's a quick cut'n paste snippet.
set termout on
set serveroutput on
set feedback off
set verify off
-- start
column 1 new_value 1 noprint
select '' "1" from dual where rownum = 0;
define param = &1 "default"
-- end
begin
dbms_output.put_line ( 'Param 1 value is ¶m' );
end;
/
exit 0
/
Execution:
$ sqlplus -s SCOTT/TIGER@ORCL @a.sql
Param 1 value is default
$ sqlplus -s POSF/POSF@ECMDB @a.sql nondef
Param 1 value is nondef
Please read "On SQL*Plus Defines" for an answer to your question.