Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbscript insert into a oracle DB using sqlplus

Status
Not open for further replies.
Oct 24, 2013
1
US
Hi need some help.

I am trying to insert some data into a oracle DB using sqlplus:

' Option Explicit
set WshShell = CreateObject("WScript.Shell")

set oEnv=WshShell.Environment("Process")


Dim WshShell, cmdString, oExec, input

cmdString = "D:\oracle\product\10.2.0\client_1\BIN\sqlplus.exe "user name"/"password"@DBName Insert into schema.tablename(SERVER_NAME, SERVER_IP, ENVIRONMENT, LAST_REBOOT, DATE_PULLED) Values ('testserver','0.0.0.0', 'Name', TO_DATE('04/05/2016 15:31:39', 'MM/DD/YYYY HH24:MI:SS'),sysdate); COMMIT;"
)

Set oExec = WshShell.Exec(cmdString)

there is no error displayed but when I check the db no data is written from this script. Not sure where to go from here.

any ideals?
 
Before (or instead of, during testing) the COMMIT, since you are still in the session that did the insert, try select * from schema.tablename; to see if the data exists during your session. Also, are you sure that errors are displayed automatically or do you need to trap them in the cmdString?

==================================
adaptive uber info galaxies (bigger, better, faster, and more adept than cognitive innovative agile big data clouds)


 
I don't know SQLPlus, but just looking at the vbscript, the line where you are assigning a value to cmdString is malformed. (unescaped double-quotes, extra close paren.)

Just taking a wild guess, but maybe the code below will get you closer?

[tt]
cmdString = "D:\oracle\product\10.2.0\client_1\BIN\sqlplus.exe username/password@DBName Insert into schema.tablename (SERVER_NAME, SERVER_IP, ENVIRONMENT, LAST_REBOOT, DATE_PULLED) Values ('testserver','0.0.0.0', 'Name', TO_DATE('04/05/2016 15:31:39', 'MM/DD/YYYY HH24:MI:SS'),sysdate); COMMIT;"

Set oExec = WshShell.Exec(cmdString)
[/tt]

Also, make sure you do not have On Error Resume Next in your code, or you will not know about runtime errors you may have.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top