Preparing Stored Procedures

From RAD Studio
Jump to: navigation, search

Go Up to Using Stored Procedure-type Datasets

As with query-type datasets, stored procedure-type datasets must be prepared before they execute the stored procedure. Preparing a stored procedure tells the data access layer and the database server to allocate resources for the stored procedure and to bind parameters. These operations can improve performance.

If you attempt to execute a stored procedure before preparing it, the dataset automatically prepares it for you, and then unprepares it after it executes. If you plan to execute a stored procedure a number of times, it is more efficient to explicitly prepare it by setting the Prepared property to True.

MyProc.Prepared := True;
MyProc->Prepared = true;

When you explicitly prepare the dataset, the resources allocated for executing the stored procedure are not freed until you set Prepared to False.

Set the Prepared property to False if you want to ensure that the dataset is re-prepared before it executes (for example, if you change the parameters when using Oracle overloaded procedures).

See Also