Subject | Re: [ib-support] Locking records with IBX |
---|---|
Author | Sandeep |
Post date | 2000-12-20T22:16:02Z |
On 20 Dec 2000, at 16:20, Ann W. Harrison wrote:
in 20 record and when they try to post it the system comes up with
an error message that someone else has changed it, that will
definately make him grumble. That's why I need to lock the record.
The way to do it is to
IBDatabase Transaction. The transaction is active by default.
This is the code:
procedure TForm1.CFLIBTable1BeforeEdit(DataSet: TDataSet);
begin
ibsqlUpdateBeforeEdit.ExecQuery;
end;
The SQL for ibsqlUpdateBeforeEdit is:
UPDATE CUSTOMER SET
CUSTOMER = ?CUSTOMER,
CONTACT_FIRST = ?CONTACT_FIRST,
CONTACT_LAST = ?CONTACT_LAST,
PHONE_NO = ?PHONE_NO,
ADDRESS_LINE1 = ?ADDRESS_LINE1,
ADDRESS_LINE2 = ?ADDRESS_LINE2,
CITY = ?CITY,
STATE_PROVINCE = ?STATE_PROVINCE,
COUNTRY = ?COUNTRY,
POSTAL_CODE = ?POSTAL_CODE,
ON_HOLD = ?ON_HOLD
WHERE
CUST_NO = ?OLD_CUST_NO
This doesn't seem to lock the record.
Sandeep
> Why do you want to lock the record?If 2 users start to edit a bill with 20 items and they change entries
in 20 record and when they try to post it the system comes up with
an error message that someone else has changed it, that will
definately make him grumble. That's why I need to lock the record.
The way to do it is to
> update it first, then read it. Something like: update foo set pk = pk;I use an single IBTansaction with IBTable, which is also default
IBDatabase Transaction. The transaction is active by default.
This is the code:
procedure TForm1.CFLIBTable1BeforeEdit(DataSet: TDataSet);
begin
ibsqlUpdateBeforeEdit.ExecQuery;
end;
The SQL for ibsqlUpdateBeforeEdit is:
UPDATE CUSTOMER SET
CUSTOMER = ?CUSTOMER,
CONTACT_FIRST = ?CONTACT_FIRST,
CONTACT_LAST = ?CONTACT_LAST,
PHONE_NO = ?PHONE_NO,
ADDRESS_LINE1 = ?ADDRESS_LINE1,
ADDRESS_LINE2 = ?ADDRESS_LINE2,
CITY = ?CITY,
STATE_PROVINCE = ?STATE_PROVINCE,
COUNTRY = ?COUNTRY,
POSTAL_CODE = ?POSTAL_CODE,
ON_HOLD = ?ON_HOLD
WHERE
CUST_NO = ?OLD_CUST_NO
This doesn't seem to lock the record.
Sandeep