IonicWind Software

IWBasic => Database => Topic started by: LarryMc on July 30, 2009, 11:33:50 PM

Title: SQL functions
Post by: LarryMc on July 30, 2009, 11:33:50 PM
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