Call Method for LCConnection

This method is used to call a stored procedure and potentially produce a result set.

This method only supports input parameters to the stored procedure. If you want data returned from a stored procedure, it must be returned to a result set, not by output parameters.

For DB2®, this method executes the stored procedure defined in the PROCEDURE property. If the procedure produces a result set, limit that result set to the number of records defined in the property RECORD_LIMIT.

Note: DB2® supports stored procedures written in C, C++, Java, and SQL. The DB2® Application Development Client supplies a stored procedure builder which generates, compiles, and links a stored procedure for use.
Note: IBM® i stored procedures may be written in RPG, C, CL, COBOL, C++, FORTRAN, PLI, and REXX. Use the Create Procedure SQL statement to generate a stored procedure. The Create Procedure statement can also be used with the System i® Interactive SQL product (5769ST1).

Defined In

LCConnection

Syntax

count = lcConnection.Call(parmFieldList, recordIndex, destFieldList)

Parameters

Parameter

Description

parmFieldList

LCFieldlist. The input parameter list for the stored procedure. You may not specify Nothing here; if the procedure has no arguments, supply an empty fieldlist.

recordIndex

Long, >=1. The index location of the parameter values within the fieldlist.

destFieldList

LCFieldlist. Fieldlist to contain the metadata of the result set. The fields in the result set will be appended to this fieldlist. If the result set metadata is not required, use Nothing.

Return Value

Value

Description

count

Long. The number of records affected by the call. Note that not all data sources return a count. LCCOUNT_UNKNOWN is returned if the count is not determined.

Example

Option Public
Uselsx "*lsxlc"  

Sub Initialize
  Dim Con As New LCConnection ("sybase") 
  Dim Parms As New LCFieldList
  Dim Result As New LCFieldList
  Dim Parm As LCField
  ' set properties to connect to both data sources
  Con.Server = "Rainbow"
  Con.Userid = "JDoe"
  Con.Password = "xyzzy"

  ' set the connection property to the stored procedure name
  Con.Procedure = "NPInsertIntoSM_ADBOOK"

  ' now connect
  Con.Connect

  ' append the new field to the fieldlist
  Set Parm = Parms.Append ("spParm", LCTYPE_TEXT)
  ' set the field to a value -- in this case it is
  ' the one parameter needed for the stored procedure
  Parm.text = " 'Edge' "

  ' using the fieldlist containing the field with the
  ' stored procedure parameter, call the stored procedure
  count = Con.Call (Parms, 1, Result)
  If count = 0 Then
    Print "No results were generated from the procedure call."
  Elseif count = LCCOUNT_UNKNOWN Then
    Print "A result set was generated but the number of results is unknown."
  Else
    Print "The stored procedure returned " & count & " records."
  End If
End Sub

Example Output

A result set was generated but the number of results is unknown.