Page 1 of 1

Batch Insert

Posted: 17.02.2006, 14:47
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,

Posted: 17.02.2006, 16:18
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

Posted: 20.02.2006, 11:07
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.

Posted: 20.02.2006, 15:49
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

Posted: 21.02.2006, 08:43
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