Batch Insert

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

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

Batch Insert

Post by cariad »

Hello,

I'm trying to run a generated SQL script as one SQL query, but keep getting errors when parsing request. I tried TZQuery.SQL.Text TZQuery.SQL.LoadFromFile(), ... but to no avail.

Am I overlooking something ? Is there a supported way to run a script against an already connected DB ?

Thanks in advance,
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

try this:

get an TZConnection and a TZReadOnlyQuery linked, up and running

pass the "batch" query to ReadOnlyQuery using
TZReadOnlyQuery1.SQL.Text := MyQueryText;

Use the TZReadOnlyQuery1.ExecSQL method

that is! :)
hope it helps
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Post by cariad »

I'm afraid it doesn't change anything. That's basically what I did (except for using TZReadOnlyQuery). I tried 6.5.1-alpha, lastest CVS, and 6.1.5-stable.

I think it's confused by the ';' at the end of an SQL statement.

Did you strip comments, or change your SQL in any way ?

I guess I'll have to split my file, and run each request on its own.
gto
Zeos Dev Team
Zeos Dev Team
Posts: 278
Joined: 11.11.2005, 18:35
Location: Porto Alegre / Brasil

Post by gto »

=\
I've tested a bit more deep than before and faced the same problem :(

One workaround is to switch off the autocommit option in ZConnection and try to insert all records, one by one, before trigger the commit procedure

it will be a "hard batch", dirty but functional :D
Use the FU!!!!!IN Google !

gto's Zeos Quick Start Guide

Te Amo Taís!
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Post by cariad »

Problem solved. It seems to be a regression from 6.1.5, but it's possible to use the TZSQLProcessor to do multi-statements.

More info in this thread http://seegernet.koolhost.de/zeosforum/ ... .php?t=299
Post Reply