problem with SUM,COUNT etc. results in SQL

Forum related to version 6.1.5 of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Moron
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 17.03.2006, 17:41

problem with SUM,COUNT etc. results in SQL

Post 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?
Moron
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 17.03.2006, 17:41

Solved

Post 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:
Post Reply