Oracle® Objects for OLE Developer's Guide 11g Release 2 (11.2) for Microsoft Windows Part Number E17727-03 |
|
|
PDF · Mobi · ePub |
OraDynaset
Returns the total number of records in the dynaset.
OraSQLStmt
Returns the number of records processed in an insert, update, or delete statement, even when there is a failure executing the SQL statement.
Not available at design time and read-only at run time.
record_count = oradynaset.RecordCountrecord_count = orasqlstmt.RecordCount
Long
Integer
Referencing this property requires that the entire result table be fetched immediately from an Oracle database to determine the count of records. Due to the potentially severe performance impact of this, the user should avoid using this property and instead execute an additional query using the COUNT(*)
clause, and use the SnapshotID
property to guarantee time consistency. For an example, see the SnapShot
property.
Referencing this property while using the ORADYN_NOCACHE
option of the CreateDynaset
method causes an implicit MoveLast
operation and makes the current record the last record in the dynaset.
RecordCount Example (OraDynaset)
This example demonstrates the use of the RecordCount
property to determine the number of records retrieved with a SELECT
statement and OraDynaset
. 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") 'Create the OraDatabase Object by opening a connection to Oracle. Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "scott/tiger", 0&) 'Create the dynaset. Set OraDynaset = OraDatabase.CreateDynaset("select * from emp", 0&) 'Display the number of records. Note that this causes 'all records to be fetched to ensure an accurate count. MsgBox OraDynaset.RecordCount & " records retrieved." End Sub
Record Count Example (OraSQLStmt)
The following example shows the number of records inserted into the database after using an INSERT
statement with OraSQLStmt
.
Dim OraSession As OraSession Dim OraDatabase As OraDatabase Dim OraDynaset As OraDynaset Dim OraSqlStmt As OraSQLStmt Dim OraPArray1 As OraParamArray Dim OraPArray2 As OraParamArray Dim I As Integer On Error GoTo ERR_array_sql 'Test case for inserting/updating/deleting multiple rows using parameter arrays 'with SQL statements Set OraSession = CreateObject("OracleInProcServer.XOraSession") Set OraDatabase = OraSession.OpenDatabase("exampledb", "scott/tiger", 0&) 'Create table OraDatabase.ExecuteSQL ("create table part_nos(partno number, description" & _ "char(50), primary key(partno))") OraDatabase.Parameters.AddTable "PARTNO", ORAPARM_INPUT, ORATYPE_NUMBER, 10, 22 OraDatabase.Parameters.AddTable "DESCRIPTION", ORAPARM_INPUT, ORATYPE_CHAR, _ 10, 50 If OraDatabase.LastServerErr <> 0 Or OraDatabase.LastServerErrText <> "" Then MsgBox "Error" End If Set OraPArray1 = OraDatabase.Parameters("PARTNO") Set OraPArray2 = OraDatabase.Parameters("DESCRIPTION") 'Initialize arrays For I = 0 To 9 achar = "Description" + Str(I) OraPArray1.put_Value 1000 + I, I OraPArray2.put_Value achar, I Next I Set OraSqlStmt = OraDatabase.CreateSql("insert into" & _ "part_nos(partno, description) values(:PARTNO,:DESCRIPTION)", 0&) If OraDatabase.LastServerErr <> 0 Or OraDatabase.LastServerErrText <> "" Then MsgBox "Error" End If MsgBox "# of records inserted : " & OraSqlStmt.RecordCount Exit Sub ERR_array_sql: MsgBox Err.Description