Subject | Re: [firebird-support] Re: Bizarre transaction/update behaviour |
---|---|
Author | Helen Borrie |
Post date | 2005-11-12T13:16:08Z |
At 12:51 PM 12/11/2005 +0000, you wrote:
delete all the detail records for the contract and year if their
item_amount is the same as the input parameter. You need to target the
*individual* detail record with *its* primary key, not the primary key of
the master.
OTOH, if you are depending on the item_amount to be a unique identifier for
each detail record, using a hierarchical PK that is made of that and the
foreign key, then you are reaping what you sowed at design time...
./heLen
>When I delete a detail record (say one out of 4), all four detailDepends on what you mean by "works well". Your update and delete SQL will
>records are deleted or when I edit a detail record, all the other
>detail records becomes identical to the edited record.
>
>My update, Refresh and delete SQL is as follows:
>
>UPDATE JOB_DETAIL
>SET
> FIN_YEAR = :FIN_YEAR,
> CONTRACT_NO = :CONTRACT_NO,
> ITEM_AMOUNT = :ITEM_AMOUNT,
> PRICE = :PRICE,
>WHERE
> FIN_YEAR = :MAS_FIN_YEAR
> and CONTRACT_NO = :MAS_CONTRACT_NO
> and ITEM_AMOUNT = :OLD_ITEM_AMOUNT
> and PRICE = :OLD_PRICE
>
>DELETE FROM
> JOB_DETAIL
>WHERE
> FIN_YEAR = :OLD_FIN_YEAR
> and CONTRACT_NO = :OLD_CONTRACT_NO
> and ITEM_AMOUNT = :OLD_ITEM_AMOUNT
> and PRICE = :OLD_PRICE
>
>SELECT
> FIN_YEAR,
> CONTRACT_NO,
> ITEM_AMOUNT,
> PRICE
>FROM
> JOB_DETAIL
>WHERE( FIN_YEAR = :FIN_YEAR
>and CONTRACT_NO = :CONTRACT_NO
> ) and ( JOB_DETAIL.FIN_YEAR = :OLD_FIN_YEAR
> and JOB_DETAIL.CONTRACT_NO = :OLD_CONTRACT_NO
> and JOB_DETAIL.ITEM_AMOUNT = :OLD_ITEM_AMOUNT
> and JOB_DETAIL.PRICE = :OLD_PRICE
> )
>
>My master table contains FIN_YEAR and CONTRACT_NO as a primary key and
>I use one transaction for this process. There is no trigger.
>
>Like said this works well after restarting the server PC, but after a
>while this behaviour happens again.
delete all the detail records for the contract and year if their
item_amount is the same as the input parameter. You need to target the
*individual* detail record with *its* primary key, not the primary key of
the master.
OTOH, if you are depending on the item_amount to be a unique identifier for
each detail record, using a hierarchical PK that is made of that and the
foreign key, then you are reaping what you sowed at design time...
./heLen