Show: Delphi C++
Display Preferences

Using Stored Procedure-type Datasets

From RAD Studio
Jump to: navigation, search

Go Up to Understanding Datasets Index


How your application uses a stored procedure depends on how the stored procedure was coded, whether and how it returns data, the specific database server used, or a combination of these factors.

To access a stored procedure on a server

  1. Place the appropriate dataset component in a data module or on a form, and set its Name property to a unique value appropriate to your application.
  2. Identify the database server that defines the stored procedure. Each stored procedure-type dataset does this differently, but typically you specify a database connection component:
    • For TStoredProc, specify a TDatabase component or a BDE alias using the DatabaseName property.
    • For TADOStoredProc, specify a TADOConnection component using the Connection property.
    • For TSQLStoredProc, specify a TSQLConnection component using the SQLConnection property.
    • For TIBStoredProc, specify a TIBConnection component using the Database property.
  3. Specify the stored procedure to execute. For most stored procedure-type datasets, you do this by setting the StoredProcName property. The one exception is TADOStoredProc, which has a ProcedureName property instead.
  4. If the stored procedure returns a cursor to be used with visual data controls, add a data source component to the data module, and set its DataSet property to the stored procedure-type dataset. Connect data-aware components to the data source using their DataSource and DataField properties.
  5. Provide input parameter values for the stored procedure, if necessary. If the server does not provide information about all stored procedure parameters, you may need to provide additional input parameter information, such as parameter names and data types. For information about working with stored procedure parameters, see Working with stored procedure parameters.
  6. Execute the stored procedure. For stored procedures that return a cursor, use the Active property or the Open method from Preparing Stored Procedures.
  7. Process any results. These results can be returned as result and output parameters, or they can be returned as a result set that populates the stored procedure-type dataset. Some stored procedures return multiple cursors. For details on how to access the additional cursors, see Fetching multiple result sets.

See Also

Personal tools
In other languages
Previous Versions
Assistance