Skip Headers
Oracle® Objects for OLE Developer's Guide
11g Release 2 (11.2) for Microsoft Windows

Part Number E17727-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

LastServerErr Property

Applies To

OraDatabase Object

OraSession Object

Description

Returns the last nonzero error code generated by an Oracle database function for the specified object. Not available at design time and read-only at run time.

Usage

error_number = oradatabase.LastServerErr
error_number = orasession.LastServerErr

Data Type

Long Integer

Remarks

This property represents the last nonzero return value from an Oracle Call Interface (OCI) database function, or zero if no error has occurred since the last LastServerErrReset request. For efficiency, only nonzero return values are returned; therefore, a nonzero value does not necessarily indicate that the most recently called OCI database function generated the error (because zero return values are not returned by way of the LastServerErr method).

Examples

This example demonstrates the use of the CreateDynaset method and the LastServerErr and LastServerErrText properties to determine whether an Oracle error has occurred, and to display the error message, respectively. Copy and paste this code into the definition section of a form. Then, press F5.

Sub Form_Load ()
 
 'Declare variables as OLE Objects.
 Dim OraSession As OraSession 
 Dim OraDatabase As OraDatabase 
 Dim OraDynaset As OraDynaset 
 
 'Create the OraSession Object.
 Set OraSession = CreateObject("OracleInProcServer.XOraSession")
 
 'Set up an error handler.
 On Error GoTo errhandler 
 
 'Create the OraDatabase Object by opening a connection to Oracle.
 Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&)
 
 'Attempt to Create the OraDynaset Object.
 'Notice that the FROM keyword is missing from the SQL statement.
 Set OraDynaset = OraDatabase.CreateDynaset("select * emp", 0&)
 
Exit Sub
 
errhandler: 
 
 'Check to see if an Oracle error has occurred.
 If OraDatabase.LastServerErr <> 0 Then
  MsgBox OraDatabase.LastServerErrText
 Else 'Must be some non-Oracle error
  MsgBox "VB:" & Err & " " & Error(Err)
 End If
 
 Exit Sub
 
End Sub