I have a call to an Oracle stored procedure. I have two linked tables from the same Oracle DB as I would like to execute the stored procedure from. Ideally, I would like to use the DSN I am using to link the tables to also access the stored procedure so I am only maintaining the link in one place. I have attempted to use the following:
But I keep getting an "ODBC--Call failed" error. The DSN with that name is working for the linked tables, just not here. I have tried putting the uid and pwd in, but I get the same result. Can anyone help me figure out what I am doing wrong?
Thanks!
Code:
Private Function GetQuestionResult(ByVal ShortName As String, ByVal SiteID As Integer) As Integer
Dim db As DAO.Database
Dim LSProc As DAO.QueryDef
Dim LRst As DAO.Recordset
Dim LSQL As String
On Error GoTo Err_Execute
Set db = CurrentDb()
Set LSProc = db.CreateQueryDef("")
'SQL to call stored procedure (with parameters)
LSQL = "BEGIN VALIDATIONQUESTIONRESULT (""" & ShortName & """, " & SiteID & "); END;"
'Use DSN ODBC connection
LSProc.Connect = "ODBC;DSN=OUTPATIENT;"
LSProc.SQL = LSQL
LSProc.ReturnsRecords = True
Set LRst = LSProc.OpenRecordset
GetQuestionResult = LRst.Fields(0).Value
Set LSProc = Nothing
Exit Function
Err_Execute:
MsgBox "The call to the Oracle stored procedure failed."
Set LSProc = Nothing
End Function
Thanks!