SQL Aggregate functions

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

SQL Aggregate functions

Post by phaworth » Mon Aug 03, 2009 11:11 pm

Having trouble getting SQL aggregate functions like COUNT and SUM to work.

A statement like the following always results in zero:

Code: Select all

put revdb_execute(gDBID,"SELECT COUNT(*) FROM Sales WHERE ProdID = 35") into field "SalesCount"
If I execute the same statement in my SQLIte admin tool, I get a non-zero result.

Same symptoms if I use other functions like SUM.

I think I'm seeing why this happens since the dictionaty says using revdb_execute is the same as using revexecuteSQL, which in turn claims to return the number of rows operated on for INSERT, UPDATE, and DELETE commands and zero for everything else. If that's the case, what command/function should I use to get the results I'm looking for?

Thanks,
Pete

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Contact:

Post by Janschenkel » Tue Aug 04, 2009 5:40 am

The revdb_execute function is meant for INSERT, UPDATE and DELETE commands, not for SELECT queries. Use the revdb_querylist function instead

Code: Select all

put revdb_querylist(return,tab,gDBID,"SELECT COUNT(*) FROM Sales WHERE ProdID = 35") into field "SalesCount"
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Tue Aug 04, 2009 5:42 am

Thanks Jan, I figured it out after I posted.

Post Reply