ZSQLProcessor.Execute gives "List Index out of bounds&a
Posted: 24.06.2010, 21:46
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()
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()