Required is true for calculate field?
Posted: 18.09.2006, 09:40
I have mysql table
[syntax="sql"]
CREATE TABLE `tabel1` (
`ID` int(11) NOT NULL auto_increment,
`Val` int(11) default NULL,
`Description` varchar(20) default NULL,
PRIMARY KEY (`ID`)
) TYPE=MyISAM;
[/syntax]
and code:
[syntax="delphi"]
procedure TForm1.Button1Click(Sender: TObject);
var MyZQuery:TZQuery;
begin
MyZQuery:=TZQuery.Create(self);
MyZQuery.Connection:=ZConnection1;
MyZQuery.SQL.Text:='select *, id+1 as Calc from tabel1';
MyZQuery.Open;
MyZQuery.Insert;
MyZQuery.FieldByName('Val').Value:='1000';
MyZQuery.FieldByName('Description').Value:='Description 1000';
MyZQuery.Post;
MyZQuery.Close;
MyZQuery.Free;
end;
[/syntax]
If you try to post on new record without set field `calc` program raised exception class EDatabaseError with message 'Field 'Calc' must have a value'.
For simple sql with calculate field is necessary to define ZUpdateObject .
It is possible to set Request = false for calculate field ?
[syntax="sql"]
CREATE TABLE `tabel1` (
`ID` int(11) NOT NULL auto_increment,
`Val` int(11) default NULL,
`Description` varchar(20) default NULL,
PRIMARY KEY (`ID`)
) TYPE=MyISAM;
[/syntax]
and code:
[syntax="delphi"]
procedure TForm1.Button1Click(Sender: TObject);
var MyZQuery:TZQuery;
begin
MyZQuery:=TZQuery.Create(self);
MyZQuery.Connection:=ZConnection1;
MyZQuery.SQL.Text:='select *, id+1 as Calc from tabel1';
MyZQuery.Open;
MyZQuery.Insert;
MyZQuery.FieldByName('Val').Value:='1000';
MyZQuery.FieldByName('Description').Value:='Description 1000';
MyZQuery.Post;
MyZQuery.Close;
MyZQuery.Free;
end;
[/syntax]
If you try to post on new record without set field `calc` program raised exception class EDatabaseError with message 'Field 'Calc' must have a value'.
For simple sql with calculate field is necessary to define ZUpdateObject .
It is possible to set Request = false for calculate field ?