Board index » delphi » Is this a BUG or not?

Is this a BUG or not?

I'm using Delphi 3 and Paradox and I have this problem:
I have table with fields:
ID            +    *
Status    I
Value    A    10

Table1 is conected to dbs (database, tiDirtyRead) and it's opened with
couple of records in it

with Table1 do begin
    Filter:='Status=1';
    Filtered:=True;
    dbs.StartTransaction;
    Edit;
    FieldByName('Status').Value:=0;
    Post;  // so the record "dissapers"
    Edit;
    FieldByName(Value').Value:='something';
    Post;
    dbs.rollback   {here I get an error: unable to modify read-only field}
end;

Any ideas ? or it has to be like that?
Marko

 

Re:Is this a BUG or not?


I can see one potential problem, although
it may not be the one you're talking about:

If you use an Autoinc field as the primary
index field you are sure to run into problems.

The value for Autoinc is not generated until
after the record is posted, which means that
the record is posted with a { nil or null or something }
value right after posting, and then is supplied
with a value. If you have a problem at some
point and a record is posted without a value
in this field, you will not be able to get any more
posts done because you will always get a
key violation (9729).
It is not as {*word*226}, but it is better db programming
if you get Max value for the field (Short or Long Integer),
Inc() by one, and then post it with the record.

Quote
Marko Filipi wrote in message <6vfi1q$m...@forums.borland.com>...
>I'm using Delphi 3 and Paradox and I have this problem:
>I have table with fields:
>ID            +    *
>Status    I
>Value    A    10

>Table1 is conected to dbs (database, tiDirtyRead) and it's opened with
>couple of records in it

>with Table1 do begin
>    Filter:='Status=1';
>    Filtered:=True;
>    dbs.StartTransaction;
>    Edit;
>    FieldByName('Status').Value:=0;
>    Post;  // so the record "dissapers"
>    Edit;
>    FieldByName(Value').Value:='something';
>    Post;
>    dbs.rollback   {here I get an error: unable to modify read-only field}
>end;

>Any ideas ? or it has to be like that?
>Marko

Re:Is this a BUG or not?


If you are at all interested, I've developed a VCL component called
AutoIncMgr.  It has two exposed methods LastKey and AllocNewKey and will
handle multiuser, will work in almost any BDE supported environment,
supports overriding Primary Key Values and will also, through LastKey return
the last assigned value.  It also autocreates its own table, so the
developer really can plug and play.

If you'd like the source, give me an email at jelr...@adelphia.net.

John Elrick

Quote
birwin wrote in message <6vfvv3$n...@forums.borland.com>...
>I can see one potential problem, although
>it may not be the one you're talking about:

>If you use an Autoinc field as the primary

Re:Is this a BUG or not?


I'm interested also. However, how about posting it to the Delphi Super
Page or something?

Quote
John Elrick wrote:

> If you are at all interested, I've developed a VCL component called
> AutoIncMgr.  It has two exposed methods LastKey and AllocNewKey and will
> handle multiuser, will work in almost any BDE supported environment,
> supports overriding Primary Key Values and will also, through LastKey return
> the last assigned value.  It also autocreates its own table, so the

--

<<<<<<------------->>>>>>>
Eivind Bakkestuen was here
           ***
"I was the second gunman
 on the grassy knoll."

Other Threads