<$BlogRSDUrl$>

Wednesday, April 06, 2005

A recent discussion on the merits of investigating Oracle behaviour with single-user scripts, which I won't link to since it rather degenerated, rather than relying on the accumulated experience of experts led me to upload a script that I use for running an arbitrary number of concurrent sqlplus scripts, this can be an effective way of simulating load on a server.

The script needs to be run from a commandline - and will echo usage back to you if you get it wrong and is available from the link at the right OraLoader or here.

For those of you that don't like downloading and running vbs scripts unseen the code is shown below.


'Name OraLoader.vbs
'
'Purpose: Run multiple sqlplus sessions concurrently
'
'Description: Run n instances of a named script simultaneously.
'
'Notes:


dim oShell
dim sqlScript
dim cmdLine
dim strUsage
dim iInstances
dim dbUser,dbPwd


strUsage = "Usage: cscript n scriptname username password"
strUsage = strUsage & vbCRLF & vbTab & "n = No of instances "
strUsage = strUsage &amp; vbCRLF & vbTab & "scriptname = path to sql script"
strUsage = strUsage & vbCRLF & vbTab & "username = database username"
strUsage = strUsage &amp; vbCRLF & vbTab & "password = database password"

if (Wscript.Arguments.count <> 4) then
Wscript.stdout.write strUsage
Wscript.Quit(1)
end if

' assign variables
iInstances = Wscript.Arguments(0)
sqlScript = Wscript.Arguments(1)
dbUser = Wscript.Arguments(2)
dbPwd = Wscript.Arguments(3)

cmdLine = "sqlplus " & dbUser &amp; "/" & dbPwd & " @" & sqlScript
set oShell = CreateObject("wscript.shell")
wscript.stdout.write cmdline
runCommand iInstances,cmdLine
set oShell= nothing

sub runCommand(iload,strCommand)

for i = 1 to iload
oShell.exec(strCommand)
next

end sub


My advice is to be very sure that the sql scripts that you call exit cleanly at the end, otherwise you can be left with a bunch of unnecessary sqlplus sessions running.

I have a number of similar scripts for loading remote servers, but the example above should give you the idea.

0 Comments
0 Comments: Post a Comment