Publish date: 2003-01-17
Stored procedure. Obtaining of row set (VB)
'SAMPLE OF WORK WITH SELECTIVE STORED PROCEDURE
'
'used SP 'MAIL_LABEL' from standart database - employee.gdb
Sub sample_8_2()
Dim cn As New ADODB.Connection
cn.Provider = "LCPI.IBProvider"
cn.Open "main:e:\database\employee.gdb", "gamer", "vermut"
cn.BeginTrans
'open CUSTOMER table
'we receive ALL columns [this is not optimal]
Dim customer As New ADODB.Recordset
customer.Open "customer", cn, adOpenForwardOnly, adLockReadOnly
Dim cmd As New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandText = "select * from mail_label(:cust_no)"
Dim sp_result As ADODB.Recordset
Dim col As Long
While (Not customer.EOF)
cmd("cust_no") = customer("cust_no")
Set sp_result = cmd.Execute
'print CUSTOMER name
Debug.Print CStr("cust_no") & ":" & customer("cust_no") & " - " & customer("customer")
'print customer mail
While (Not sp_result.EOF)
Debug.Print "--------------------"
For col = 0 To sp_result.Fields.Count - 1
Debug.Print sp_result(col).Name & ":" & sp_result(col)
Next col
sp_result.MoveNext
Wend
Debug.Print "------------------------------------"
sp_result.Close
customer.MoveNext
Wend
cn.CommitTrans
End Sub 'sample_8_2
