2010年3月17日 星期三

Lotus Notes 連接oracle的另一種想法

想法透過 Oracle Objects for OLE 的方式進行連接Oracle 資料庫,正在測試中:
Example:
Q:
What do I need on my R5.0.12 domino server to make a connection to an Oracle 8.x server?

I would like to do this using Java or LotusScript directly to the Oracle database (No DSN).
Thanks,
-Lance

Ans:

RE: Making a connection to Oracle
Posted by Siddharth Gupta on 5.May.03 at 上午 09:17 using a Web browser
Category: Lotus ConnectorsRelease: Lotus Connectors - All ReleasesPlatform: Windows 2000


You need oracle objects for ole to do this. Basically if you have an Oracle client installed on your machine then you will have this.

You will need to instatioate the oracle sessions by a code similar to this:


 
  Set OraSession = CreateObject("OracleInProcServer.XOraSession")
'Get the OraClient object.
Set OraClient = OraSession.Client
'Create a named OraSession Object. Alternatively, you could use the CreateNamedSession method of the OraSession Object.
Set NamedOraSession = OraClient.CreateSession("Anyname")
'Create the OraDatabase Object by opening a connection to Oracle.
Set OraDatabase = NamedOraSession.OpenDatabase(DbName,Username,Password)




資料來源:Enterprise Integration Forum
/****************************************/
2010/3/18 下午測試成功,範例如下:
/***************************************/
 
Sub Postopen(Source As Notesuidocument)
    Dim OraSession As Variant
    Dim ODatabase As Variant
    Dim ODynaset As Variant
   
    Set OraSession = CreateObject("OracleInProcServer.XOraSession")
     'Get the OraClient object.
    Set OraClient = OraSession.Client
     'Create a named OraSession Object. Alternatively, you could use the CreateNamedSession method of the OraSession Object.
    Set OraSession = OraClient.CreateSession("FIAC")
     'Create the OraDatabase Object by opening a connection to Oracle.
    Set OraDatabase = OraSession.OpenDatabase("FIAC","fiac/fiac",0&)
   
    If (OraDatabase Is Nothing ) Then
        Messagebox "ORACLE Connect Error"
        Exit Sub
       
    End If
    Set ODynaset=OraDatabase.CreateDynaset("select * from figc",0&)
    Msgbox ODynaset.fields("ComLab").value
       '取得Oracle 資料
    Call source.FieldSetText("ComLab", ODynaset.fields("ComLab").value )
    ODynaset.close
    OraDatabase.close
End Sub




沒有留言: