Page 1 of 1

Problems with DBGrid

Posted: 16.04.2010, 15:37
by carlocat
Hello,
i've got this situation:

- Delphi 2010
- TZquery (every version, even the ZEOSLIB_TESTING_REV800_COMPACT version)
- TDBGrid linked to the datasource of the TZquery

At the beginning i've got these DataSet:

recno field1 field2 field3

1 R R R
2 G G G
3 H H H
4 P P P

And the cursor positionated at recno n° 2.

Then i make a simple update operation:

table.Edit;
table.FieldByName('FIELD2').AsString := 'X';
table.Post;

After post i've got this result:

recno field1 field2 field3

1 R R R
2 P P P
3 H H H
4 G X G

And the cursor positionating at recno n° 4!

Is this a problem of bookmark??

Thank you in advance
Carlo

Posted: 19.04.2010, 09:30
by carlocat
Anyone can help me please?

Posted: 20.04.2010, 08:30
by guidoaerts
Carlocat,
Do you have an index or filter active?
What is the code for positioning the cursor?

Guido

Posted: 20.04.2010, 15:12
by Wild_Pointer
carlocat,

you haven't noted what DB you are using.
I guess that you don't have the order by statement in your query. Because of that when you post the changes, the record goes to the end of your result set.
When testing on postgresql I get similar results but the order changes not immediately after POST, but after REFRESH.
So please try using sorting or ORDER BY and see if the behavior changes.

Posted: 23.04.2010, 15:21
by carlocat
Hello to everyone,
sorry i've forgotten the DB. I'm using PostgresSQL. I don't have filter and order by. The ZQuery using a sortorder to field1. Removing the field it works. So my question is:"Why the dataset change if i change the field2 that is not sorted"?

Thank you in advance,
Carlo

p.s. sorry for my bad english!

Posted: 23.04.2010, 15:33
by Wild_Pointer
carlocat,
Removing the field it works.
do you mean that then you remove field1 from TZQuery.SortedFields the record jumping stops ?

Have tried using zeos not form testing branch ?
Anyway I've tried editing fields and didn't observe the behavior you did.
Would you please provide a simple test case? SQL to create a table and the source of a small program that illustrates the behavior would be enough.

Posted: 30.04.2010, 12:59
by guidoaerts
after all, after the editing the records are sorted on field1, but in descending order (r,p,h,g).... before the editing, the records are not sorted on field1 (r,g,h,p)
isn't that what is should do?
guido

Posted: 10.05.2010, 15:29
by carlocat
Sorry for the delay, i was out from my office for a project.
First of all thank you very much for the answers: I give you a simple project to replicate the problem:

This is the table:

CREATE TABLE test
(
recno serial NOT NULL,
field1 character(10),
field2 character(10),
field3 character(10),
codext integer,
data timestamp without time zone,
CONSTRAINT test_pkey PRIMARY KEY (recno)
)
WITH (OIDS=FALSE);
ALTER TABLE test OWNER TO admin;

And in the attachment you will find the example project.

Of course you need to check the properties of ZConnection...

Thank you again in advance.
Carlo

Posted: 12.05.2010, 11:46
by trupka
carlocat,

i did some tests with your example and can confirm same problem in Delphi2007 (so, it's not D2009/10) issue. Problem disappears when ZQuery1.Options[doDontSortOnPost] := false so I think this bug is not directly related to Bookmars.
Can someone else confirm this?

Posted: 17.05.2010, 20:09
by carlocat
So, do you confirm that there is a bug?

Thank you very much.
Carlo