Create a gist now

Instantly share code, notes, and snippets.

SublimeText 3 version for OracleSQL file (
import sublime
import re
import os.path
import os
from . import oracle_lib
from Default import exec as execmod
RE_ENTITIES = re.compile("^\\((.+?)/(0):[0-9]+\\) ([0-9]+):[0-9]+ (.+)$", re.M)
class OracleExecCommand(execmod.ExecCommand):
def run(self, dsn="", **kwargs):
if not dsn and not kwargs.get("kill", False):
# if cmd is empty, open the command_palette with the available build list
self.window.run_command("show_overlay", {"overlay": "command_palette", "text": "Build: " + kwargs.get("prefix", "")})
# Find entities declaration in source
self.entities = oracle_lib.find_entities(self.window.active_view())
# Create a string for the in of sql command
if len(self.entities) == 0:
sqlfilter = self.quote("''")
sqlfilter = self.quote(",".join("'%s'" % entity for entity in self.entities.keys()))
(directory, filename) = os.path.split(self.window.active_view().file_name())
cmd = ["sqlplus.exe", "-s", dsn, "@", os.path.join(sublime.packages_path(), 'OracleSQL', 'RunSQL.sql'), self.quote(filename), sqlfilter]
super(OracleExecCommand, self).run(cmd, "", "^Filename: (.+)$", "^\\(.+?/([0-9]+):([0-9]+)\\) [0-9]+:[0-9]+ (.+)$", working_dir=directory, **kwargs)
def quote(self, str):
return '"{:s}"'.format(str)
def append_data(self, proc, data):
# Update the line number of output_view with the correct line number of source view
orgstr = data.decode(self.encoding)
datastr = orgstr
posoffset = 0
for re_ent in RE_ENTITIES.finditer(orgstr):
pos = re_ent.span(2)
pos = (pos[0] + posoffset, pos[1] + posoffset)
sourceoffset = self.entities[]
sqlerrorline = int(
sourceline = sqlerrorline + sourceoffset
datastr = datastr[:pos[0]] + str(sourceline) + datastr[pos[1]:]
posoffset += len(str(sourceline)) - 1
super(OracleExecCommand, self).append_data(proc, datastr.encode(self.encoding))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment