0

I'm getting this dynamic sql warning after trying to fetch results from this query:

Warning: ibase_fetch_assoc(): Dynamic SQL Error SQL error code = -804 Incorrect values within SQLDA structure

SELECT VOORRAADAUTO.*, AUTOMERK.*, VOORRAADAUTO.OMSCHRIJVING as uitvoeringnaam 
FROM VOORRAADAUTO 
LEFT JOIN AUTOMERK ON AUTOMERK.AUTOMERKID = VOORRAADAUTO.AUTOMERKID 
WHERE VOORRAADAUTO.SOORTVOORRAADSTATUSID = 2 AND VOORRAADAUTO.TOTAALCONSUMENT > 0 ORDER BY AUTOMERK.OMSCHRIJVING DESC, VOORRAADAUTO.TOTAALCONSUMENT, VOORRAADAUTO.MODELOMSCHRIJVING;

And this php code:

        $p_sql = ibase_prepare($sql);
        $rs = ibase_execute($p_sql);

        while($row = ibase_fetch_assoc($rs)){
            $auto = new auto($row);
            $this->list[] = $auto;      
        }

How come there are incorrect values? And how do you solve this problem?

mewiki
  • 135
  • 4
Monstertov
  • 23
  • 6
  • You should check for errors from `ibase_prepare` and `ibase_execute`. – Barmar Sep 12 '15 at 14:44
  • ibase_errmsg isn't returning any errors – Monstertov Sep 12 '15 at 14:53
  • Looks like this error have lots of [**Causes**](https://www.google.co.ve/search?espv=2&q=incorrect+values+within+SQLDA+structure+interbase&spell=1&sa=X&ved=0CBkQvwUoAGoVChMIyJ-WvuDxxwIVCM2ACh3fGQUT&biw=1407&bih=871). Parameters, Dlls, Drivers, Connection string, etc. So we cant test all those. – Juan Carlos Oropeza Sep 12 '15 at 15:00

2 Answers2

0

You can always try to run the sql direct on the database.

Because the Sql query looks ok, I can only think maybe there is a typo in a field name or doesn't return rows. Or the where fields aren't numeric

Also may I suggest use alias instead of full table name, that help to read the query.

SELECT V.*, A.*, V.OMSCHRIJVING as uitvoeringnaam 
FROM VOORRAADAUTO V
LEFT JOIN AUTOMERK A
   ON A.AUTOMERKID = V.AUTOMERKID 
WHERE V.SOORTVOORRAADSTATUSID = 2 AND V.TOTAALCONSUMENT > 0 
ORDER BY A.OMSCHRIJVING DESC, V.TOTAALCONSUMENT, V.MODELOMSCHRIJVING;
Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
0

Don't know if you solved it already, but i had the same error with a simple query like:

SELECT * FROM "any_Table" WHERE "id"=1

It worked for me after i replace the * with the column name:

SELECT "id", "Name" FROM "any_table" WHERE "id"=1 

I think it has something to do with the interbase driver, i found this: Bug report

It appears that the php interbase client can't handle boolean fields, after i had changed the boolean field in a integer the select * works.

I'm using XAMPP, PHP Version 5.6.15, with interbase XE7 on windows and used gds32.dll from the interbase install (12.0.4.357).

mewiki
  • 135
  • 4