SQLplus decode to execute scripts

前端 未结 2 401
后悔当初
后悔当初 2020-12-21 13:21

I am writing a script to be run in sqlplus 11. I have a user defined variable called compression. If this is true then I want to run the script CreateTablesCompression, othe

2条回答
  •  时光说笑
    2020-12-21 14:05

    SQL> host cat foo.sql
    set scan on
    define compression=&1
    col scr new_value script
    set term off
    select decode('&compression', 'true', 'CreateTablesCompression', 'CreateTables') scr from dual;
    set term on
    @@&script
    
    SQL> @foo true
    run CreateTablesCompression.sql
    SQL> @foo false
    run CreateTables.sql
    

提交回复
热议问题