Problem running oracle script from command line using sqlplus

前端 未结 6 596
暖寄归人
暖寄归人 2021-01-11 20:14

I\'m having a problem trying to run my sql script into oracle using sqlplus. The script just populates some dummy data:

DECLARE 
  role1Id NUMBER;
  user1Id          


        
6条回答
  •  温柔的废话
    2021-01-11 20:53

    The command line

    sqlplus username/password@server/dbname @Setup.sql
    

    mentioned above means that sqlplus should execute the script Setup.sql and wait further commands interactively (if script does not do exit explicitly). This is a normal behavior of sqlplus.

    sqlplus terminates in three cases:

    • Failure (for some errors you can change if it terminates or not. See WHENEVER plsql-command)
    • Explicit exit (both interactive and sript)
    • End of STDIN (EOF)

    Either from interactive mode or from script you can send ^Z character to softly terminate input flow. Interactively you just press Ctrl+Z,Enter.

    And, of course, you may redirect STDIN, and take it from file, not from keyboard. There are two similar ways to do this:

    1) sqlplus username/password@server/dbname

    In both cases sqlplus will terminate after the script execution because of EOF in the input flow.

提交回复
热议问题