is it possible to define default value of a variable in sql scripts
Hi,
I was thinking of a way to assign a default value to a variable without any prompt by the script as we do in shell script.
To make my query more clear, consider the example.
suppose we have a sql script like test.sql with contents
===========================================
define x=&1
declare
x1 number;
begine
x1:=nvl(&x,10);
dbms_output.put_line(x1);
end;
/
===========================================
even though I am using nvl it will prompt for value of 1 which needs user interference. for example if I run test.sql output is as below:
=============
SQL> @test
Enter value for 1:
10
=============
Is there any way to avoid sql from prompting for values of variables for which we want it to take a default value (if not specified as input argument)
Thanks
now if i run this as
sql>@test 10
it executes