How to create a menu in SQLPlus or PL/SQL

后端 未结 6 1535
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 22:15

I have several scripts that I would like to start from a menu presented to the SQLPlus user. Something like:

Please make a selection:
1: Do script a

6条回答
  •  攒了一身酷
    2020-12-11 23:01

    You can execute scripts from a master script:

    CASE LOWER(&v_script_selection)
      WHEN 'a' THEN
        @script_a.sql
      WHEN 'b' THEN
        @script_b.sql
      WHEN 'c' THEN
        @script_c.sql
      ELSE
        DBMS_OUTPUT('No such option available')
    END
    

    &variablename is used to refer to the variable variablename in SQLPlus, much the same way $variablename is used in shell scripts. If variablename is undefined, then SQLPlus prompts the user for a value.

    You can provide a path relative to the master script - the example relies on the supporting scripts to be in the same directory.

提交回复
热议问题