Board index » delphi » Problem with database constraints

Problem with database constraints

Hello: I'm working with an Interbase database server 6.0, and Delphi 5.0
enterprise, and I manage database operations using cached updates. The
problem is the next:
I have defined in a table a constraint like this: Check(Field1 <= Field2)
I start a transaction and Post a record in the table with Field1 = -40 and
Field2 = -40.
After that I apply and commit the updates from the cache (without closing
the transaction). The next step is finding the record I previosly appended,
and making Field1 and Field2 values = 0. When I try to apply updates of the
table, the constraint indicates me that there is an error, but the fields
match the condition: Field1=0, Field2=0, so Field1 <= Field2 is true. When I
drop the constrant from the database, the operation finalizes OK and the
final result is getting Field1 and Field2 = 0 in database.
I don't have to say that I commit the transaction when the changes are done.
The constraint doesn't happen if I insert the record from SQL Explorer or
another interbase administrator.
What's happening here? Am I wrong in some way? Am I doing the right
operations?
Please help me. Thank you very much.

Daniel Alvarez

 

Re:Problem with database constraints


Daniel,

Could it be that you are updating Field1=0 before (and separately) to
Field2=0. I suggest you use the Delphi 5 BDE SQL Monitor utility to see
exactly what is going on. It is very useful in situations like these.

Regards,
Danny.

Quote
"Daniel Alvarez" <dalva...@flashmail.com> wrote in message

news:3c06a6ab_1@dnews...
Quote
> Hello: I'm working with an Interbase database server 6.0, and Delphi 5.0
> enterprise, and I manage database operations using cached updates. The
> problem is the next:
> I have defined in a table a constraint like this: Check(Field1 <= Field2)
> I start a transaction and Post a record in the table with Field1 = -40 and
> Field2 = -40.
> After that I apply and commit the updates from the cache (without closing
> the transaction). The next step is finding the record I previosly
appended,
> and making Field1 and Field2 values = 0. When I try to apply updates of
the
> table, the constraint indicates me that there is an error, but the fields
> match the condition: Field1=0, Field2=0, so Field1 <= Field2 is true. When
I
> drop the constrant from the database, the operation finalizes OK and the
> final result is getting Field1 and Field2 = 0 in database.
> I don't have to say that I commit the transaction when the changes are
done.
> The constraint doesn't happen if I insert the record from SQL Explorer or
> another interbase administrator.
> What's happening here? Am I wrong in some way? Am I doing the right
> operations?
> Please help me. Thank you very much.

> Daniel Alvarez

Re:Problem with database constraints


Thanks. I'll try.

Daniel

Danny Mavromatis <dmavroma...@comops.com.au.remove_this> escribi en el
mensaje de noticias 3c06bae5_2@dnews...

Quote
> Daniel,

> Could it be that you are updating Field1=0 before (and separately) to
> Field2=0. I suggest you use the Delphi 5 BDE SQL Monitor utility to see
> exactly what is going on. It is very useful in situations like these.

> Regards,
> Danny.

Other Threads