Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Executing an EDB Procedure from an EWB Module
Sun, Sep 2 2018 8:06 PMPermanent Link

Richard Harding

Wise Nutrition Coaching

I have created my first EWB module that performs EDB backups and restores as well as a number of other database and store functions.

What I would really like to do is to execute a procedure. Since the EDB Manager can execute a procedure, it would appear that this must be possible but I cannot work out how to do this from looking at the EDB Manager source.

Is it possible to execute an EDB procedure from a EWB module?

Richard
Mon, Sep 3 2018 5:47 AMPermanent Link

Uli Becker

Richard,

> Is it possible to execute an EDB procedure from a EWB module?

Sure, no problem.

1. Drop a TEDBStoredProc component on your form (for modules always make sure that "AutoSessionName" of the sesson is true, otherwise it would not be thread safe).
2. Assign the procedure name.
3. Add params (maybe passed from your EWB app).
4. Run the procedure and send back the result.

e.g.:

      with MyProc do
      begin
        if Prepared then
          Unprepare;
        StoredProcName := FName;
        Prepare;
        for i := 0 to RequestParams.Count - 1 do
          MyProc.Params[i].asString := RequestParams.ValueFromIndex[i];
        try
          ExecProc;
          SendContent('');
        except
          on e: Exception do
            SendError(HTTP_INTERNAL_ERROR, e.message);
        end;
      end;

Uli

 
Mon, Sep 3 2018 6:56 AMPermanent Link

Richard Harding

Wise Nutrition Coaching

Great - thank you Uli.

Richard.
Image