Incorrect error "Update Failed On Complex Query"
Moderators: gto, EgonHugeist
Incorrect error "Update Failed On Complex Query"
There are 2 tables in my DB: PLUSA and PLU__
In program, there is TZTable connected to PLU__. When I try to post updates to it, it gives "Cannot update a complex query with more then one table"
Under debugger, I can see that in TZGenericCachedResolver.DefineTableName some columns have tablename = PLU__ and some are PLUSA.
How can I resolve this problem (except that try to rename PLU__ table)?
P.S. When opening table, in TZAbstractResultSetMetadata.ReadColumnByName table names are already wrong
That is, some columns are from PLUSA (those with the same name with PLU__ table)
I suspect that there is a select from a system table, something like "select field_name where table_name like plu__" and it returns plusa fields
In program, there is TZTable connected to PLU__. When I try to post updates to it, it gives "Cannot update a complex query with more then one table"
Under debugger, I can see that in TZGenericCachedResolver.DefineTableName some columns have tablename = PLU__ and some are PLUSA.
How can I resolve this problem (except that try to rename PLU__ table)?
P.S. When opening table, in TZAbstractResultSetMetadata.ReadColumnByName table names are already wrong
That is, some columns are from PLUSA (those with the same name with PLU__ table)
I suspect that there is a select from a system table, something like "select field_name where table_name like plu__" and it returns plusa fields
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Yes, I suppose that would help for your case...
Can you find some time to find out where exactly TZAbstractResultSetMetadata.GetTables and TZAbstractResultSetMetadata.GetColumns are called from. I think it might be sufficient to use the AddEscapeCharToWildcards metadatafunction before passing the tablename to the lookup functions. My wild guess is that this might happen in the parsesql or zdbcresultsetmetadata units.
You can find more information on this topic at http://fisheye2.atlassian.com/changelog/zeos?cs=266 and the link to the bug report you find there.
I have no time at the moment to look into this myself. Sorry.
If you don't wan us to forget about it and you can't spend the time yourself, please file a bug report at http://zeosbugs.firmos.at/
Mark
Can you find some time to find out where exactly TZAbstractResultSetMetadata.GetTables and TZAbstractResultSetMetadata.GetColumns are called from. I think it might be sufficient to use the AddEscapeCharToWildcards metadatafunction before passing the tablename to the lookup functions. My wild guess is that this might happen in the parsesql or zdbcresultsetmetadata units.
You can find more information on this topic at http://fisheye2.atlassian.com/changelog/zeos?cs=266 and the link to the bug report you find there.
I have no time at the moment to look into this myself. Sorry.
If you don't wan us to forget about it and you can't spend the time yourself, please file a bug report at http://zeosbugs.firmos.at/
Mark
That problem is database consider char like '_' and '%' like wildchar so procedure detect 2 of '_' like a wildchar and then do a search for all the tables which begin with the name 'plu'. You can:
1. rename table plu__ or plusa
2. change FillWildcards procedure, contained in ZdbcMetadata.pas
procedure TZAbstractDatabaseMetadata.FillWildcards;
begin
try
SetLength(WildcardsArray,2);
WildcardsArray[0]:='_';
WildcardsArray[1]:='%';
except
WildcardsArray:=nil;
end;
end;
removing line WildcardsArray[0]:='_';
But bear in mind by this way you avoid a problem that could be raised in
other parts
1. rename table plu__ or plusa
2. change FillWildcards procedure, contained in ZdbcMetadata.pas
procedure TZAbstractDatabaseMetadata.FillWildcards;
begin
try
SetLength(WildcardsArray,2);
WildcardsArray[0]:='_';
WildcardsArray[1]:='%';
except
WildcardsArray:=nil;
end;
end;
removing line WildcardsArray[0]:='_';
But bear in mind by this way you avoid a problem that could be raised in
other parts
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
duzenko,
I think the problem is in the way TZAbstractResultSetMetadata.GetTableColumns calls Metadata.GetColumns. Try changing the call
to
or something similar. (This is untested code but you may get the idea...)
Please, test it. If it works I'll add your patch to the official Zeoslib code base.
Mark
I think the problem is in the way TZAbstractResultSetMetadata.GetTableColumns calls Metadata.GetColumns. Try changing the call
Code: Select all
Result := Metadata.GetColumns(TableRef.Catalog,
TableRef.Schema, TableRef.Table, '');
Code: Select all
Result := Metadata.GetColumns(TableRef.Catalog,
TableRef.Schema, Metadata.AddEscapeCharToWildcards(TableRef.Table), '');
Please, test it. If it works I'll add your patch to the official Zeoslib code base.
Mark
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
I didn't get an answer from your tests, so we didn't change anything.Please, test it. If it works I'll add your patch to the official Zeoslib code base.
Please provide a nice and working solution for this specific problem. As there's no real development team at the moment, this will have to be fixed by the community.
Mark
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
duzenko,
Did you try this?
Have a look at http://zeosbugs.firmos.at/view.php?id=28, and more specifically to comment 111 there.
Mark
Did you try this?
Because this function *should* escape the '_' in a way it's not handled as a pattern anymore.I think the problem is in the way TZAbstractResultSetMetadata.GetTableColumns calls Metadata.GetColumns. Try changing the call
Code:
Result := Metadata.GetColumns(TableRef.Catalog,
TableRef.Schema, TableRef.Table, '');
to
Code:
Result := Metadata.GetColumns(TableRef.Catalog,
TableRef.Schema, Metadata.AddEscapeCharToWildcards(TableRef.Table), '');
or something similar. (This is untested code but you may get the idea...)
Have a look at http://zeosbugs.firmos.at/view.php?id=28, and more specifically to comment 111 there.
Mark