Page 1 of 1

[solved] ZQuery.Open internally requests metadata

Posted: 21.09.2012, 10:06
by AlexGA
Hello!

First of all, excuse me for my English.

Problem: Some of RDBMS functions (like FOUND_ROWS() in
MySQL) must be called immediately after SQL command executive. When we
call TZQuery.Open, we send to server SQL statment, after that
TZQuery internally requests metadata from server. So, TZQuery.Open not
only send SQL request to server, but send commands (or another sql statments) to
get metadata. If after that we call RDBMS function (ZQueryCount.SQL =
'SELECT FOUND_ROWS() AS RecsCount'; ZQueryCount.Open), function return
wrong result.

Question: How i can send request to RDBMS, after method TZDataSet.Open send
SQL statement to server, but before TZDataSet.Open requests metadata?

I think Event like TZDataSet.AfterSqlSendBeforeGetMetadata can help,
but i do not now architecture of ZEOS library and can't implement
event.

Any ideas?

Posted: 21.09.2012, 10:14
by EgonHugeist
AlexGA,

Nice proposal, but a BIG job. Actually i have no idea what the purpose of FOUND_ROWS is. Why not check the TZDataSet.RecordCount?

Next proposal: TZConnection.UseMetadata.:= false (untested so it would be interesing to know if it works property..) That option does suppress fetching the MetaInformations.

What do you think?

Posted: 21.09.2012, 10:38
by AlexGA
EgonHugeist wrote:AlexGA,

Nice proposal, but a BIG job. Actually i have no idea what the purpose of FOUND_ROWS is. Why not check the TZDataSet.RecordCount?

Next proposal: TZConnection.UseMetadata.:= false (untested so it would be interesing to know if it works property..) That option does suppress fetching the MetaInformations.

What do you think?
If we use SQL statment with limitation of result records count (like SELECT TOP 100 ....) TZDataSet.RecordCount store actually fetched records count from server (not greater then 100). Function FOUND_ROWS return total record count of previous SQL but without limitation. It need to implement statistic like "FETCHED ROWS 100 OF 2546"

I do not know if TZDataSet without metaInformation will be work correctly...
I will try TZConnection.UseMetadata:= false.

Posted: 21.09.2012, 11:00
by EgonHugeist
AlexGA,

Ok now i understand the purpose of this command. Nice to know.

Accordingly UseMetadata=false:

It will work nice for tables/views but i know it won't work with the TZStoredProc component. Here the Metainformations are required to get the parameters running.

I hope you question is solved..

Posted: 21.09.2012, 12:43
by AlexGA
I set TZConnection.UseMetadata := false

All work fine!!!

Thank you very much!

Question is solved.

Posted: 08.10.2012, 23:53
by mdaems
Just for your information : setting this UseMetadata to false also has side effects. One of them is that all datasets will not be able to perform updates without using a TZUpdateSQL component as zeoslib can't find out how to update the data on the database side.

Mark