Page 1 of 1

Error : Field xxx must have a value

Posted: 18.01.2007, 04:55
by arch-vile
Halo,

I use Delphi 7 with Zeos 6.6.0-beta, before used Zeos 6.6.0-beta I used an old version Zeos 6.1.5-stable.

I have problem in Delphi with new Zeos component. Before upgrade to 6.6.0-beta the code work fine. Error occured when checking the value of that field. If the value of that field is NULL or when the IF condition below is FALSE.

Below is quoted of my code.

------begin--------
if not zquery1.FieldByName('disc_cash').IsNull then
zquery2.FieldByName('disc_cash').AsCurrency := zquery1.FieldValues['disc_cash'];
------end----------

The error message appear :
... exception class EDatabaseError with message 'Field 'disc_cash' must have a value'.

Anyone can help me how to fix it??

thank u..
.arifin

i used mysql 4.1

Posted: 18.01.2007, 08:41
by mdaems
I suppose disc_cash in zquery2 is defined as 'not null default 0' (or something similar putting a default on it). Try to set the required property of the field to false before inserting.

Mark

Posted: 18.01.2007, 10:05
by arch-vile
Hello Mark,

Yes, the problem on zQuery2, default for field required property is set to true. On old version of zeos, default field required property is set to false.

Thank u Mark.
arifin

Posted: 18.01.2007, 12:17
by mdaems
Hi arifin,

The reason is now we check the table definitions on the database. Maybe we should also check if a database default value is provided.

I hope somebody can write a small patch to check this. (If it's not already on the forum yet)

Mark