Executing an action stored procedure with a TIBStoredProc
Go Up to Using Stored Procedures that Perform Actions on Data
To retrieve individual values from stored procedure output parameters using a TIBStoredProc component:
- Instantiate a stored procedure component.
- In the
StoredProcNameproperty, specify the name of the stored procedure. - If the stored procedure requires input parameters, supply values for the parameters using the
Paramsproperty orParamByNamemethod. - Invoke the
ExecProcmethod.
For example, the InterBase stored procedure ADD_EMP_PROJ, below, adds a new row to the table EMPLOYEE_PROJECT. No dataset is returned, and no individual values are returned in output parameters.
CREATE PROCEDURE ADD_EMP_PROJ (EMP_NO SMALLINT, PROJ_ID CHAR(5))
AS
BEGIN
BEGIN
INSERT INTO EMPLOYEE_PROJECT (EMP_NO, PROJ_ID)
VALUES (:EMP_NO, :PROJ_ID);
WHEN SQLCODE -530 DO
EXCEPTION UNKNOWN_EMP_ID;
END
SUSPEND;
END
The Delphi code to execute the ADD_EMP_PROJ stored procedure is:
with StoredProc1 do begin StoredProcName := ‘ADD_EMP_PROJ’; ExecProc; end;