Executing an action stored procedure with a TIBStoredProc

From InterBase
Jump to: navigation, search

To retrieve individual values from stored procedure output parameters using a TIBStoredProc component:

  1. Instantiate a stored procedure component.
  2. In the StoredProcName property, specify the name of the stored procedure.
  3. If the stored procedure requires input parameters, supply values for the parameters using the Params property or ParamByName method.
  4. Invoke the ExecProc method.

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;