Problem using TZQuery.Append

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Problem using TZQuery.Append

Post by cariad »

Hello,

I ran into a problem when trying to do bulk insert using TZQuery.Append/Post.

Here's an excerpt of my code in case I forgot something :

Code: Select all

Query := TZQuery.Create(nil);
Query.Connection := Connection;
Query.SQL.Text := 'select * from '+TableName+' where 0=1';
Query.Open;

Query.Append;

Query.Fields[0].Value := Par.Id;
Query.Fields[1].Value := Par.Val;

Query.Post;
Query.Free;
The problem occurs with Query.Post. I traced it to ZGenericCachedResolver.PostUpdates. SQL before FillStatement seems Ok (table name found, all fields recognized), FillStatement seems to fetch data just fine, but the SQL query used in ExecuteUpdatePrepared is wrong ("INSERT INTO table VALUES (?,?,?,?...);"). I have this problem with (at least) Firebird and Oracle using Zeos-6.6.3-stable.

I think the code above should be ok, but feel free to correct me I if forgot something. I'm not really familiar with the Zeos ; do you have any advice where to look to debug it further ?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

What's the actual error you get? And you are sure no data gets inserted?
Because the question marks may be OK. Actually this means the statement and the values are sent separately to the server.

If you want to send me sa sample program, please do send a complete (zipped) project using an EMBEDDED fb lib and the corresponding datafile. Mail it to zeoslib at gmail point com. But for now just an answer to the first question may be enough.
(you're lucky, wednesday is my weekly day off. You can try to get me on one of the IM channels that are visible in my profile if you want. It may take some time before I reply however. Working outside...)

Mark
Image
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Post by cariad »

What's the actual error you get?
sigh...

I was writing the error I get is an exception triggered by CheckInterbase6Error() when I notice something.
Because the question marks may be OK.
That's what catch my attention and I assumed the generated SQL was incorrect. Turns out the beginning of the exception message was about a foreign key violation. When feeding Query.Fields[x].Value I forgot to handle null values for foreign keys and tried to insert it as 0 which of course didn't go as planned.

I suppose looking like a dumbass worldwide is part of the job ;) Thanks anyway for your input and your time and enjoy your wednesday afternoon.
Post Reply