Saturday, November 19, 2016

Using Gitora in PL/SQL Developer dual or multi session mode

While browsing around today i saw the same question about how to use Gitora in PL/SQL Developer on the Allround Automations forum as well as on the Gitora Q&A site.

Besides answering this question on both sites, as i just started this blog, i thought i could make a blog about it to get some practice, so  here it is.

For those not familiar with Gitora, it s a version control system for PL/SQL.
You can read more about it on www.gitora.com

PL/SQL Developer single, dual or multi session mode

You can run PL/SQL Developer in 3 modes:  single session, dual session or multi session.

In single session mode, all program windows use the same database connection, so using Gitora in this mode is straightforward. just open a command window and execute
api_gitora.login('username','password');

In dual-session or multi-session mode, windows use different connections, so we need another approach. There are three ways to use Gitora in dual or multi-session.

1) Use Afterconnect.sql

In the PL/SQL Developer installation directory there is a file called Afterconnect.sql.
This script is executed whenever a new connection to the database is made.
By default the sql file is empty, so just add something like:
begin
   api_gitora.login('username','password');
end;

2) Use a database after logon trigger

You can create a database after logon trigger that will log you on to Gitora when a connection is made. This approach will not only work for PL/SQL developer but for any application that can make a connection to the database. I use this option for our development team using Gitora.
Check how to do this here.

3) Create a custom menu button

You can create a menu button that will execute a script in the active connection.
Here are the steps how to do this:
- create a script file with api_gitora.login, for example on d:\Gitora_login.sql
- in menu 'Tools' choose 'Configure Tools'
- in the dialog, click the little button n the right side 'New'
- name your tool, for example 'Gitora login'
- fill in some other details like below


- close the dialog

The second tab 'Menu' should allow you to place the tool in a specific menu directly, but it did not work for me, but there is another option.
Right click anywhere on the gray area next to a menu, you will get a popup dialog.
Choose 'Customize'



The new tool you created is under 'Commands', and scroll to the bottom to see 'User defined tools'
No you can drag the 'Gitora logon' tool from the right onto a menu in PL/SQL developer.



Now, when you need to logon to Gitora, you can just click the button.

Have fun using Gitora!

No comments:

Post a Comment