Global odbc

I have a Notes app with several forms with views and view actions (lotuscript). Several view actions must open an ODBC connection and run a stored procedure on the AS400 to update the db2 database each time they are run.

I would like to make the odbc connection global, ie. within a script library, so that the code (in the action or in the script library) can check to see if the odbc connection is connected. If it finds no connection, connect and run the stored procedure. If it finds the connection, just call the stored procedure.

I want to get away from the odbc connection having to be re-instantiate every single time a view action is run.

First, is this doable? And if so, could someone post sample code illustrating how this would be done, both the code for the odbc connection in the script library and the code in the view action.

Any help would be greatly appreciated.

Subject: global odbc

Does this ODBC driver provide connection pooling? If so, there should be relatively little overhead, even if your code seams to establish the connection on every click. If not, you should probably see much bigger improvements by switching to a native driver for you database (which will most probably support connection pooling AND will be more efficient in plain everything it does).

If you still want to go that route, the most “global” scope you can have is that of a script library loaded by the view indeed. Define the connection object in the libraries Declaration section and open the connection in the libraries Initialize event. If you use that lib from the view’s global Options, the connection object should be available to all actions. Be careful to always set all properties correctly, that might be different from action to action.

Subject: RE: global odbc

I believe it is a Client Access ODBC driver. We run a Domino server on an iSeries (AS400) IBM system. I think it supports connection pooling. I’ll check into it.

What I see happening now is when the action is clicked, there is a second or two pause, then a messagebox comes up saying it is establishing a connection, then it connects and goes away. Takes about 8 seconds or more everytime. If the user has to do this several times in a row, 8 seconds becomes an eternity.

I currently have a logon function that does the actual connecting:

If Not conAS400.ConnectTo(strDataSource, strUserName, strPassWord) Then

Goto ExitFunction

End If

conAS400.ThreadSafeDriver = True

fcnLogon = True

If I move that code to the Initialize event of the library, how do I call it? How and when does that code run?

Thanks for the help.

Subject: RE: global odbc

The code in a script libraries Initialize event runs as soon as the lib is used in a module (for the first time, subsequent use statements referencing the same lib, e.g. through nested libraries calls should not trigger the event again). There’s nothing more you have to do, just include the use statement. However, you do have to declare the connection object (and any other objects, that should be available to all view actions) in the script libraries Declarations section, not in the Initialize.

I know plain nothing about iSeries stuff in general and about this driver in particular, but I agree, that the behavior you described is not really acceptable from a user’s point of view.

Subject: RE: global odbc

I got it to work, somewhat.

Thanks.