Accessing an Oracle table

A Lotus Connector is a powerful means for accessing an Oracle table. To have it work properly, the machine from which the Lotus code is being executed (wether a Domino server for Web operations or a Notes client) needs a working copy of the Oracle client software. The Lotus Conector will simply use some client libraries for accessing the networked database, so the client needs not be running before executing the Lotus code, nor it needs any custom configurations for accessing the database, like any changes to the tnsnames.ora file.

In fact, all of the conection data that would usually go into the tnsnames.ora configuration file, can be much more conveniently stored inside a LotusScript library, like the following

'Connection_Oracle: Option Public Option Declare Const connection_Host = "" Const connection_Port = "1525" Const connection_SID = "extprd" Const connection_UserId = "Notes Log" Const connection_Password = "Notes Log" Dim connection_Server As String Sub Initialize connection_Server = {} _ & {(DESCRIPTION=} _ & {(ADDRESS_LIST=} _ & {(ADDRESS=} _ & {(PROTOCOL=TCP)(Host=} & connection_Host & {)(Port=} & connection_Port & {)} _ & {)} _ & {)} _ & {(CONNECT_DATA=} _ & {(SID=} & connection_SID & {)} _ & {)} _ & {)} End Sub

Booking a company ID

This is a very simple use of the Lotus Connector clockwork.
There is a SAP application where companies are added to a database using a SAP data entry screen. For some reason, the time at which all the needed data is available, is too far in the future (;-), and some guy needs the company ID as soon as possible, well before the SAP application will provide one.

Behind the scenes, the SAP application returns as a company ID the record ID of that company into the companies Oracle table. Finally that record ID is a value of an Oracle sequence, which is incremented whenever a new record is added to the companies table. So it is possible to book a company ID, simply by incrementing the sequence. This means that no record is added to the database, but that ID is unique and will never be used for any other record.

'BookCompanyID: Option Public Option Declare Uselsx "*LSXLC" Use "Connection Oracle" Function BookCompanyID As Long On Error Goto HandleError Dim session As New LCSession session.ClearStatus Goto Begin HandleError: Dim errmsg As String errmsg = "Error " & Err & Chr$( 10 ) _ & Getthreadinfo( 1 ) & ":" & Erl & Chr$( 10 ) If session.Status <> LCSUCCESS Then errmsg = errmsg & session.GetStatusText Else errmsg = errmsg & Error$ End If Error Err, errmsg Begin: Dim sqlNextval As String sqlNextval = { SELECT SQ_COMPANIES.NEXTVAL FROM DUAL } Dim connection As New LCConnection( "oracle8" ) connection.Server = connection_Server connection.UserId = connection_UserId connection.Password = connection_Password '------------------------------------------------------------------------------------------- connection.Connect Dim fields As New LCFieldList Call connection.Execute( sqlNextval, fields ) Dim nextVal As LCField Set nextVal = fields.Lookup( "NEXTVAL" ) Call connection.Fetch( fields ) BookCompanyID = nextVal.Value( 0 ) Done: connection.Disconnect '------------------------------------------------------------------------------------------- End Function

Leave a Reply

Your email address will not be published. Required fields are marked *