Previous Topic

Next Topic

Inhoudsopgave

Book Index

TIsahStoredProc Component

TIsahStoredProc

Description

TIsahStoredProc is a unidirectional dataset which encapsulates a stored procedure in a database application. Unidirectional datasets are designed for quick lightweight access to database information, with minimal overhead. They can send an SQL command to the database server, and if the command returns a set of records, obtain a cursor for accessing those records. However, unidirectional datasets can only retrieve a unidirectional cursor. They do not buffer data in memory, which makes them faster and less resource-intensive than other types of datasets. However, because there are no buffered records, unidirectional datasets are also less flexible than other datasets. Many of the capabilities introduced by TDataSet are either unimplemented in unidirectional datasets, or cause them to raise exceptions. For example:

The only supported navigation methods are the First and Next methods. Most others raise exceptions. Some, such as the methods involved in bookmark support, simply do nothing.

There is no built-in support for editing because editing requires a buffer to hold the edits. The CanModify property is always False, so attempts to put the dataset into edit mode always fail. You can, however, use unidirectional datasets to update data using an SQL UPDATE command or provide conventional editing support by connecting the dataset to a client dataset.

There is no support for filters, because filters work with multiple records, which requires buffering. If you try to filter a unidirectional dataset, it raises an exception. Instead, all limits on what data appears must be imposed using the SQL command that defines the data for the dataset.

There is no support for lookup fields, which require buffering to hold multiple records containing lookup values. If you define a lookup field on a unidirectional dataset, it does not work properly.

Details

Use a TIsahStoredProc object in the database application to use a stored procedure on a database server. A stored procedure is a grouped set of statements, stored as part of a database server's metadata (just like tables, indexes, and domains), that performs a frequently repeated, database-related task on the server and passes results to the client.

Many stored procedures require a series of input arguments, or parameters, that are used during processing. TIsahStoredProc provides a Params property that enables an application to set these parameters before executing the stored procedure. TIsahStoredProc reuses the Params property to hold the results returned by a stored procedure. Params is a list of values. Depending on server implementation, a stored procedure can return either a single set of values, or a result set similar to the result set returned by a query.

TIsahStoredProc Properties

Property Property Active: Boolean (R/W)

Specifies whether or not a dataset is open. Use Active to determine or set whether a dataset is populated with data. When Active is false, the dataset is closed; the dataset cannot read data and data-aware controls can not use it to fetch data. When Active is true, the dataset can be populated with data.

Property Property DatabaseName: String (R/W)

Specifies the name of the database associated with this dataset. Use DatabaseName to specify the name of the database to associate with this dataset component. DatabaseName should match the name of a database component used in the application.

Note: Attempting to set DatabaseName in case a database already associated with this component is open, will cause an exception.

Property Property Params: Params list (R)

Stores the input and output parameters for a stored procedure. Access Params at runtime to set input parameter names, values, and data types dynamically (at design time use the Parameters editor to set parameter information). Params is a list of parameter values. An application can also access Params after executing a stored procedure to retrieve the output parameters returned to the procedure by the server.

Property Property StoredProcName: String (R/W)

Identifies the name of the stored procedure on the server for which this object is an encapsulation. Set StoredProcName to specify the name of the stored procedure to call on the server. If StoredProcName does not match the name of an existing stored procedure on the server, an exception is raised when the application attempts to prepare the procedure prior to execution.

TIsahStoredProc Methods

Method Method ExecProc

Executes the stored procedure.

Code Snippet

Set spCountry = IsahObjects.Get("TIsahStoredProc")

With spCountry

.Name = "spCountry"

.DatabaseName = "dbIsahAdmin"

.StoredProcName = "IP_get_Country"

.Left = 312

.Top = 8

End With