Project Description

It's a script that allows to execute SQL directly from UltraEdit (and many other text editors which allow to use external tools)

Installation Guide

  1. Save file sql_exe.vbs in any directory
  2. Edit it: replace values for variables ora_db, ora_user_name and ora_password
  3. In UltraEdit select menu item Advanced -> Tool Configuration...
  4. Set the following values:
    1. Command Line: cscript.exe <full path to sql_exe.vbs file> "%f"
    2. Working Directory: %p
    3. Menu Item Name: <Enter some name here>
    4. Check options: Save Active File, Output to List Box, Show DOS Box, Capture Output
  5. Press Insert and OK
ultraedit_toolconf.png

File sql_exe.vbs

Full file content - version 1.0. Copy, Paste and Save it.

' Created by Aleksei Vassiljev
' Version 1.0
' Usage:
' cscript.exe sql_exe.vbs "%f"


Dim ora_db
Dim ora_user_name
Dim ora_password

'--------------------------
' NB: Edit these values:
'--------------------------
ora_db = "DB01"
ora_user_name = "USER1"
ora_password = "USER1"
'---------------------------

Dim sFileName
Dim sFileType
Set arg = WScript.Arguments
Set sh = WScript.CreateObject("WScript.Shell")

sFileName = arg.Item(0)
sFileType = get_fileFile(sFileName)

If sFileType = "SQL" Then
	load_sql(sFileName)
Else
	WScript.Echo "Unknown file type"
End If

Set sh = Nothing
Set arg = Nothing

Function load_sql(fname)
	Dim path
	path = "cmd.exe /C sqlplus " & ora_user_name & "/" & ora_password & "@" & ora_db & " @""" & fname & ""
	p = sh.run(path)
	sh.AppActivate(p)
	WScript.Sleep(500)
	sh.SendKeys("quit")
End Function

Function get_fileFile(fname)
	Set sql_file = New RegExp
	sql_file.Pattern = "^.*\.(sql|pkb|pkh)$"
	sql_file.Global = True
	sql_file.IgnoreCase = True
	sql_count = sql_file.Execute(fname).Count
	If sql_count > 0 Then
		get_fileFile = "SQL"
		Exit Function
	End If
	get_fileFile = "OTHER"
	Set sql_file = Nothing
End Function

System Requiremens



Last edited Dec 14, 2010 at 10:54 PM by alekseiv, version 4

Comments

No comments yet.