April 16, 2024, 06:12:50 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


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