|
From: Jolly G. G. <jgg...@gm...> - 2006-11-30 16:49:51
|
Your post helped me in two ways:
1) It let me know there was a SQL Toolbar! Now I use that.
2) And it gave me that macro to use if I end up having too many scripts to run
Thanks Eric.
I have another issue about T-SQL section terminators, but I'll move
that to a new post. I can't seem to create two Stored Procs on the
same SQL file.
On 11/30/06, Eric Berry <el...@gm...> wrote:
> > Here's the code for a macro I want to run. How can I modify it to run
> > "creation.sql" (which is open), instead of the current view?
> >
> > I have two or three SQL scripts to run and I want to automate it.
> >
> > sql.SqlTextPublisher.publishBuffer(
> > view, sql.SqlUtils.getSelectedServerName(sql.SqlUtils.getProject(view))
> > );
>
> The SQL plugin's "Publish Buffer" functionality is dependent on the
> current buffer. So all you need to do is bring that buffer to the
> front before calling the method.
>
> Here's 2 ways of doing what you want, though seems like a lot of work
> if the file is already open in jEdit. Why not just go to the file and
> click the "Execute Buffer" button in the SQL plugin tool bar?
>
> First way - I recommend this way because if the sql plugin code
> changes but the action name does not, then your macro will still work.
> [code]
> String sqlFilePath = "/some/path/to/creation.sql";
> jEdit.openFile(view, sqlFilePath);
> EditPlugin sqlPlugin = jEdit.getPlugin("sql.SqlPlugin", true);
> PluginJAR sqlPluginJar = sqlPlugin.getPluginJAR();
> ActionSet sqlPluginActionSet = sqlPluginJar.getActionSet();
> sqlPluginActionSet.getAction("sql.publishBuffer").invoke(view);
> [/code]
>
> Second way - Shorter, but is dependent on the sql plugin code to
> publish a buffer.
> [code]
> String sqlFilePath = "/some/path/to/creation.sql";
> jEdit.openFile(view, sqlFilePath);
> sql.SqlTextPublisher.publishBuffer(
> view, sql.SqlUtils.getSelectedServerName(sql.SqlUtils.getProject(view))
> );
> [/code]
>
> Hope this helps,
> Eric
>
> --
|