Default value for paramteters not passed SQLPlus script

后端 未结 2 830
暖寄归人
暖寄归人 2021-02-07 15:19

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         


        
相关标签:
2条回答
  • 2021-02-07 16:09

    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 &param' );
    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

    0 讨论(0)
  • 2021-02-07 16:13

    Please read "On SQL*Plus Defines" for an answer to your question.

    0 讨论(0)
提交回复
热议问题