Board index » delphi » How to modify data on several tables with ibdataset?

How to modify data on several tables with ibdataset?

Hi,
I do : Select * from SALARIE S, BULLETIN B Where S.CODESAL = B.CODESAL_BUL
in the SelectSQL statement; and I want modify data in the table SALARIE  and
BULLETIN,so I have tried this in the ModifySQL statement :

Update SALARIE S, BULLETIN B Set S.NOM=:nom, B.DATE_PAYE=:date_paye Where
S.CODESAL=:codesal And B.CODEBUL=:codebul

But It doesn't work: error on "," after update! ( we can't put several
tables in an update statement?)

How to do this ?
thanks,
fred.

 

Re:How to modify data on several tables with ibdataset?


You cant update two tables with single UPDATE statement. You must use two
UPDATE statements in two different components. What you can do is write a
AfterPost event and trigger ExecQuery of another IBSQL component witch
updates the BULLETIN table like:

procedure ...AfterPost(DataSet: TDataSet);
begin
    with BullUpdateSQL do
    begin
        Params.ByName('CODESAL').AsString :=
            DataSet.FieldByName('CODESAL').AsString;
        Params.ByName('PAY_DATE').AsDateTime :=
            DataSet.FieldByName(PAY_DATE').AsDateTime;
        ExecQuery;
    end;
end;

--
Sergio Samayoa
Lgica Software
http://www.geocities.com/logicasw/

Re:How to modify data on several tables with ibdataset?


Thanks It works!

In fact I have done this:

Select * from SALARIE S, BULLETIN B Where S.CODESAL = B.CODESAL_BUL
in the SelectSQL statement

And: Update SALARIE NOM=:nom Where CODESAL=:codesal in the ModifySQL
statement
Because if there is no update statement I can't edit in the grid

And in the AfterPost I do what you say to update the BULLETIN table

fred.

"Sergio Samayoa" <serg...@terra.com.gt> a crit dans le message news:
3b2f5fbb_1@dnews...

Quote
> You cant update two tables with single UPDATE statement. You must use two
> UPDATE statements in two different components. What you can do is write a
> AfterPost event and trigger ExecQuery of another IBSQL component witch
> updates the BULLETIN table like:

> procedure ...AfterPost(DataSet: TDataSet);
> begin
>     with BullUpdateSQL do
>     begin
>         Params.ByName('CODESAL').AsString :=
>             DataSet.FieldByName('CODESAL').AsString;
>         Params.ByName('PAY_DATE').AsDateTime :=
>             DataSet.FieldByName(PAY_DATE').AsDateTime;
>         ExecQuery;
>     end;
> end;

> --
> Sergio Samayoa
> Lgica Software
> http://www.geocities.com/logicasw/

Other Threads