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

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

Moderators: gto, EgonHugeist

Post Reply
pmoor
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 24.06.2010, 21:31

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

Post 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()
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply