title: How to Execute an Oracle SQL Statements with VBScript
body: <p>I am trying to execute an Oracle SQL statement or Oracle Functions through Microsoft VBScript and the loop throught the result set or display the value returned by the function</p>
  
  <p>So far I have managed to connect to Oracle via SQLPlus*, but now I am stuck. Can anybody help?</p>
  
  <pre><code>
  Dim output
  
  Dim WshShell, oExec, input 
  
  set WshShell = CreateObject("WScript.Shell")
  
  set oEnv=WshShell.Environment("Process") 
  
  cmdString = "C:\Oracle\11g\product\11.1.0\ruby\BIN\sqlplus.exe -S stradmin/stradmin@ruby select * from dual"
  Set oExec = WshShell.Exec(cmdString) 
  
  
  WScript.Echo "Status" & oExec.Status
  
  
  Do While oExec.Status = 0 
  
       WScript.Sleep 2 
  
  Loop 
  
  
  
  input = "" 
  
  
  
  Do While Not oExec.StdOut.AtEndOfStream 
  
            input = input & oExec.StdOut.Read(1) 
  
  Loop 
  
  
  
  wscript.echo input 
  </code></pre>