RAD Studio |  |

Executing Stored Procedures That Don't Return a Result Set
See Also
Collapse All

When a stored procedure returns a cursor, you execute it the same way you populate any dataset with records: by setting Active to True or calling the Open method.

However, often stored procedures do not return any data, or only return results in output parameters. You can execute a stored procedure that does not return a result set by calling ExecProc. After executing the stored procedure, you can use the ParamByName method to read the value of the result parameter or of any output parameters:

Copy Code

    MyStoredProcedure.ExecProc;  { does not return a result set }
    Edit1.Text := MyStoredProcedure.ParamByName('OUTVAR').AsString;

Copy Code

    MyStoredProcedure->ExecProc(); // Does not return a result set
    Edit1->Text = MyStoredProcedure->ParamByName("OUTVAR")->AsString;

Note: TADOStoredProc does not have a ParamByName method. To obtain output parameter values when using ADO, access parameter objects using the Parameters property.
Tip: If you are executing the procedure multiple times, it is a good idea to set the Prepared property to True.
See Also

Fetching Multiple Result Sets

Preparing Stored Procedures

Working with Stored Procedure Parameters

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!