A representation of a stored procedure call.

Syntax

[<oRef> =] new StoredProc( )

<oRef>

A variable or property—typically of a Form or Report object—in which to store a reference to the newly created StoredProc object.

Properties

The following tables list the properties, events, and methods of the StoredProc class. For details on each property, click on the property below:

Property

Default

Description

active

false

Whether the stored procedure is open and active or closed

baseClassName

STOREDPROC

Identifies the object as an instance of the StoredProc class

className

(STOREDPROC)

Identifies the object as an instance of a custom class. When no custom class exists, defaults to baseClassName 

database

null

Database to which the stored procedure is assigned

handle

 

BDE statement handle

name

Empty string

The name of custom object

params

AssocArray

Associative array that contains Parameter objects for the stored procedure call

parent

null

Container form or report

procedureName

Empty string

Name of the stored procedure

rowset

Object

Reference to the rowset object containing the results of the stored procedure call

session

null

Session to which the stored procedure is assigned

 

Event

Parameters

Description

canClose

 

When attempting to close stored procedure; return value allows or disallows closure

canOpen

 

When attempting to open stored procedure; return value allows or disallows opening

onClose

 

After stored procedure closes

onOpen

 

After stored procedure first opens

 

Method

Parameters

Description

execute( )

 

Executes stored procedure (called implicitly when active property is set to true)

prepare( )

 

Prepares stored procedure call

requery( )

 

Rebinds and executes stored procedure

unprepare( )

 

Cleans up when stored procedure is deactivated (called implicitly when active property is set to false)

Description

Use a StoredProc object to call a stored procedure in a database. Most stored procedures take one or more parameters as input and may return one or more values as output. Parameters are passed to and from the stored procedure through the StoredProc object’s params property, which points to an associative array of Parameter Objects.

Some stored procedures return a rowset. In that case, the StoredProc object is similar to a Query object; but instead of executing an SQL statement that describes the data to retrieve, you name a stored procedure, pass parameters to it, and execute it. The resulting rowset is accessed through the StoredProc object’s rowset property, just like in a Query object.

Because stored procedures are SQL-server-based, you must create and activate a Database object and assign that object to the StoredProc object’s database property. Standard tables do not support stored procedures.

Next, the procedureName property must be set to the name of the stored procedure. For most SQL servers, the BDE can get the names and types of the parameters for the stored procedure. On some servers, no information is available; in that case you must include the parameter names in the procedureName property as well.

Getting or specifying the names of the parameters automatically creates the corresponding elements in the StoredProc object’s params array. Each element is a Parameter object. Again, for some servers, information on the parameter types is available. For those servers, the type properties are automatically filled in and the value properties are initialized. For other servers, you must supply the missing type information and initialize the value to the correct type.

To call the stored procedure, set its active property to true. If the stored procedure does not generate a rowset, the active property is reset to false after the stored procedure executes and returns its results, if any. This facilitates calling the stored procedure again if desired, after reading the results from the params array.

If the stored procedure generates a rowset, the active property remains true, and the resulting rowset acts just like a rowset generated by a Query object.

You can dataLink components in a form to fields in a rowset, or to the Parameter objects in the params array.