Page 1 of 1

ZSQLProcessor.Execute gives "List Index out of bounds&a

Posted: 24.06.2010, 21:46
by pmoor
I'm new to ZEOS have found it works great I my app but I did find an error that appeared. It gave "List Index out of bounds" in the Execute method.

What I was trying to do was load in a script file from a previously generated mysqldump file. In this file the last line is a comment line. This what causes the problem. I found a fix by changing the Execute method to the following :

SQL.Text := GetStatement(I);
if SQL.StatementCount > 0 then << -- added this line
begin << -- added this line
Statement := CreateStatement(SQL.Statements[0].SQL, nil);
SetStatementParams(Statement, SQL.Statements[0].ParamNamesArray, FParams);
Statement.ExecuteUpdatePrepared;
end; << -- added this line
Statement := nil;

What happens is that as the Execute goes through the various statements it thinks it has one left (the comment) but once the GetStatement is called it responsed with nothing.

I know I probably should have stripped any comments first but it was a nice and easy implementation to just load the file directly into the ZSqlProcessor.Script.LoadFromFile()

Posted: 29.08.2010, 21:38
by mdaems
Hi,

Nice you've found a solution for this problem. I suppose you didn't look at the reason why TZSQLProcessor.statementcount was wrong after the parse call?
I'm sure your patch works correctly, but it would be better when the count was correct as well.
Do you have some time to investigate this a little more?

Mark