April 25, 2024, 08:49:37 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


SQL functions

Started by LarryMc, July 30, 2009, 11:33:50 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

SQL has a group of built in functions that come in handy.

I wanted to use the MAX function which returns the maximum value in a specified field.
Here's a way to do it:
int rec_no=0
hstmt = dbExecSQL(pdb,"SELECT MAX(recno) AS rec_no FROM author")
IF LEN(dbGetErrorCode(hstmt))
PRINT "Error Text: ", dbGetErrorText(hstmt)
endif
IF hStmt
dbGetData(hstmt,1,rec_no)
dbFreeSQL(hstmt)
endif


Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library