Page 1 of 1

problem with SUM,COUNT etc. results in SQL

Posted: 18.03.2006, 03:08
by Moron
Sorry if this is too stupid question (and sorry for my english too) I tried to find some solution but wasn't successful.

I am not able to obtain results of SQL functions like SUM,MAX, LAST_INSERT_ID() with IZStatement like You can see below

Part of my code:

Code: Select all

var
      	sqlDotaz : string;
        statement : IZStatement;
        resultSet : IZResultSet;
      begin
        statement := dmCentral.dmCentralni.zCentrKonekt.DbcConnection.CreateStatement;
        sqlDotaz := 'select Sum(pocet_volnych) from typ_materialu';
        resultSet := Statement.ExecuteQuery(sqlDotaz);
        sumVolnych := resultSet.GetLong(1);
when program executes

Code: Select all

 resultSet.GetLong(1);
it colaps and write error "row data is not available"
TZMySQLResultSet.FRowHandle=nil but I really don't know why. Can someone please please help?

Solved

Posted: 19.03.2006, 13:19
by Moron
After many hours I finally figure it out. So For everyone who has a similar problem:

Ensure that You call at least once

Code: Select all

 resultSet.next
before you try to call something like

Code: Select all

resultSet.GetLong(1)
:roll: