Subject Re: [firebird-support] XSQLDA index out of range
Author Helen Borrie
At 12:04 AM 2/12/2008, you wrote:
>> I get 'XSQLDA index out of range' when I try to make my queries
>> What is causing this?

This is similar to saying "I had a pet flea. It has escaped. Have you seen it?"

It sounds like a Delphi array error and "make my queries active" is a Delphi concept so I guess you are using some Delphi implementation of the API to connect your application to data. So - proceeding on that assumption....

The XSQLDA is the structure that applications use to pass input values across the API and to receive output values back from a successful request.

For a SELECT statement you will have one or two XSQLDAs: one for sending input parameters (if the SELECT statement has parameters) and another for receiving outputs. An XSQLDA carries one XSQLVAR for each input column it is passing or output column it is to receive. The XSQLVARs have a strict order from left to right. Firebird does not support named parameters: application interfaces have to refer to parameters or columns by their position (first, second, third, etc.)

Delphi statement components typically wrap the XSQLVARs for each XSQLDA into Delphi var arrays: xsqlda[0] is the first parameter or output column, xsqlda[1] is the second...and so on. Also, since XSQLVAR carries a lot of information about the parameter or column it represents, Delphi components typically extract these elements into other arrays and access the information by referring to the xsqlvar elements of the appropriate xsqlda by their array indexes.

No two Delphi component suites do these array-linking tricks in exactly the same way, but the main arrays associated with an XSQLDA are usually properties of a statement object, and are named Params[] and Fields[] (or Columns[]), respectively.

So - one can guess that your code is trying to reference more input parameters or output columns than a Params or Fields array was configured to provide; and Delphi is objecting by telling you "XSQLDA index out of range".

The possible causes of such an error are many lost fleas.....possibilities include trying set Active a statement that doesn't return a dataset (insert, update, delete and executable procedure calls should use an Execute/ExecSQL method); using an old version of your components that does not support the XSQLDA/XSQLVAR structures in newer Firebird versions; not preparing a statement; and many more...

If you need some help finding out why *your* particular Delphi implementation is playing up, I recommend finding the support list for YOUR components and posting a *useful* question there. To find out how to post a useful question, read this: