"List index out of bounds error" while creating TOracleQuery-object

andrehoog

Member
Sometimes (sorry but I couldn't reproduce this), I'm getting "List index out of bounds (..)" errors while creating the TOracleQuery object.

I'm using D5, DOA 406 and Oracle 10g.

Code:
function TBlahBlah.CreateQuery(SQLLines : TStringList; Options : TCreateQueryOptions = [cqoExecute, cqoOptimize]; Session : TOracleSession = nil) : TOracleQuery;
var r: char;
begin
  if Session = nil then
    Session := FDefaultSession;

  try
    r := 'a';
    result := TOracleQuery.Create(Application); // <<-- error
    r := 'b';
    result.Session := Session;

    for i := 0 to SQLLines.Count - 1 do
      result.SQL.Add(SQLLines[i]);

    if cqoExecute in Options then
      result.Execute;

    if FDebug then
      Notify('[TBlahBlah.CreateQuery]: ' + SQLLines.Text);
  except
    ...
    // log error message and value of r
    ...
    raise;
  end;
end;
I wonder whether replacing Application with Nil solves the problem, but I doubt it.

Any ideas?

Thanks in advance!
 
I wonder whether replacing Application with Nil solves the problem, but I doubt it.
Actually, I think it will. I have never used an Application as a component owner though, only forms, datamodules, and nil.
 
Ah, so it actually does make a difference. We'll just have to try this and see if errors will occur in the future. It's quite odd that the error message only appears every now-and-then. This makes debugging a real pain in the ... (exactly).

Thanks for your advice!

- Andr
 
Back
Top