Subject | Re: [IBO] found ibo (?) bug |
---|---|
Author | Helen Borrie (TeamIBO) |
Post date | 2002-05-21T23:58:07Z |
At 05:54 PM 21-05-02 +0200, you wrote:
failed locate takes you to the end of the dataset. Then you place the
dataset in Edit mode. Because there is no record there, Delphi calls
Insert instead of Edit and inserts a new row. You immediately call Post
without adding any data - causing IBO to attempt to post this newly
inserted record. Because a required field is null, you are getting the error.
Your assignment statement won't work unless you tell IBO that the field is
a Boolean - IB has no Boolean type. You would need to set the IB_BOOLEAN
attribute using the ColumnAttributes property; otherwise your assignment
statement would need to be
procedure TForm1.IBOTable1BeforePost(DataSet: TDataSet);
begin
IBOTable1X.asBoolean:='F';
end;
By the way, this is not valid SQL in IB 6 or Firebird:
CREATE DOMAIN BOOL AS
VARCHAR(1)
DEFAULT "F"
NOT NULL
CHECK (VALUE IN ("T","F"))
Strings can not have double-quote delimiters.
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com
>I've stumbled upon a bug. It's quite easy to reproduce:You are observing perfectly normal, regular behaviour for TDataset. The
>
>1. Create a table having a "boolean" field:
>
>CREATE TABLE COUNTRIES (
> ID INTEGER NOT NULL,
> NAME VARCHAR(60),
> X BOOL NOT NULL);
>
>CREATE DOMAIN BOOL AS
>VARCHAR(1)
>DEFAULT "F"
>NOT NULL
>CHECK (VALUE IN ("T","F"))
>
>
>2. Drop a TIBOTable and a tbutton
>
>procedure TForm1.Button1Click(Sender: TObject);
>begin
> with IBOTable1 do
> begin
> open;
> first;
> showmessage('1st time: '+IBOTable1NAME.asString); // valid, all well
> Edit;
> Post;
>
> Locate('ID', 0, []); // non existant row
> showmessage('2nd time: '+IBOTable1NAME.asString); // valid, still shows
>the same as before
>
> Edit;
> Post; // exception here: "X is a required field"
> end;
>
>Cheers.
>end;
>
>adding :
>
>procedure TForm1.IBOTable1BeforePost(DataSet: TDataSet);
>begin
> IBOTable1X.asBoolean:=false;
>end;
>
>makes no difference.
failed locate takes you to the end of the dataset. Then you place the
dataset in Edit mode. Because there is no record there, Delphi calls
Insert instead of Edit and inserts a new row. You immediately call Post
without adding any data - causing IBO to attempt to post this newly
inserted record. Because a required field is null, you are getting the error.
Your assignment statement won't work unless you tell IBO that the field is
a Boolean - IB has no Boolean type. You would need to set the IB_BOOLEAN
attribute using the ColumnAttributes property; otherwise your assignment
statement would need to be
procedure TForm1.IBOTable1BeforePost(DataSet: TDataSet);
begin
IBOTable1X.asBoolean:='F';
end;
By the way, this is not valid SQL in IB 6 or Firebird:
CREATE DOMAIN BOOL AS
VARCHAR(1)
DEFAULT "F"
NOT NULL
CHECK (VALUE IN ("T","F"))
Strings can not have double-quote delimiters.
regards,
Helen Borrie (TeamIBO Support)
** Please don't email your support questions privately **
Ask on the list and everyone benefits
Don't forget the IB Objects online FAQ - link from any page at
www.ibobjects.com