3 Replies Latest reply: Mar 5, 2013 4:28 AM by Mihael RSS

    Accept input from commandline

    HJHorst
      Hi,

      I have an sql file with multiple accept statements.
      I would like to run this script from the DOS commandline, and supply the script with values for the accept statements.
      How can I do this? (I do not want to alter the sql-file for this)

      Regards,
      HJH
        • 1. Re: Accept input from commandline
          Mihael
          I have an sql file with multiple accept statements.
          I would like to run this script from the DOS commandline, and supply the script with values for the accept statements.
          How can I do this? (I do not want to alter the sql-file for this)
          Create text file and put one value per line in proper order. For example, you have the following script script.sql :
          accept V1 char prompt 'Enter value for V1:'
          accept V2 char prompt 'Enter value for V2:'
          
          prompt Your input : &V1 &V2
           
          exit
          Text file values.txt can be the following:
          ABC
          DEF
          Then use the following syntax:
          sqlplus.exe /nolog @script.sql < values.txt
          • 2. Re: Accept input from commandline
            HJHorst
            Thanks a lot. It works!

            Is this documented somewhere? I couldn't find it.

            Groeten,
            HJH
            • 3. Re: Accept input from commandline
              Mihael
              This is standard OS behaviour, using file to redirect user input.
              Good luck.