Using a Stored Procedure
Go Up to Working with Stored Procedures
How a stored procedure is used in a Delphi application 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.
In general terms, to access a stored procedure on a server, an application must:
- 1. Instantiate a
TIBStoredProc
component and optionally associate it with a stored procedure on the server. Or instantiate aTIBQuery
component and compose the contents of itsSQL
property to perform either aSELECT
query against the stored procedure or anEXECUTE
command, depending on whether the stored procedure returns a result set. For more information about creating aTIBStoredProc
, see Creating a Stored Procedure Component. For more information about creating aTIBQuery
component, see Working with Queries. - 2. Provide input parameter values to the stored procedure component, if necessary. When a stored procedure component is not associated with stored procedure on a server, you must provide additional input parameter information, such as parameter names and data types. For more information about providing input parameter information, see Setting Parameter Information at Design Time.
- 3. Execute the stored procedure.
- 4. Process any result and output parameters. As with any other dataset component, you can also examine the result dataset returned from the server. For more information about output and result parameters, see Using Output Parameters and Using the Result Parameter. For information about viewing records in a dataset, see Using Stored Procedures that Return Result Sets.