KB#00365-Programs demonstrating SQL access to an ODBC-defined datasource
Title:
Programs demonstrating SQL access to an ODBC-defined datasource
Description:
The following example shows how to use SQL to query a database. It uses a datasource named 'Salesl_History', but any valid datasource can be used in its place. Note that it uses an aggregate function and a parameter in the query.
0005 INPUT "Enter Sales Person:",SP$
0010 SQLOPEN (1)"Sales_History"
0020 SQLPREP (1)"select count(*) as Total_Sales from sales_log where salesperson = ?"
0030 DIM RCT$:SQLTMPL(1)
0040 SQLEXEC (1)SP$
0050 LET RCT$=SQLFETCH(1)
0060 PRINT SP$," had",RCT.Total_Sales," sales"
===================================================
0010 SQLOPEN (1,MODE="ExecDirect=1")"ACCESS_CD_DB"
0020 SQLPREP (1)"select * from discs"
0030 SQLEXEC (1)
0040 DIM A$:SQLTMPL(1)
0050 LET A$=SQLFETCH(1,ERR=0160)
0060 PRINT "Artist:"+A.ARTIST$
0070 PRINT "Title:"+A.TITLE$
0080 PRINT "Year:",A.YEAR
0090 PRINT "Songs:",A.SONGS
0100 PRINT "Rating:",A.RATING
0110 PRINT "Category:",A.CATEGORY$
0130 PRINT $0D0A$
0140 INPUT "Press <CR> to continue...",*
0145 PRINT $0D0A$
0150 GOTO 0050
0160 CLOSE (1)
Last Modified: 02/23/2004 Product: PRO/5
BASIS structures five components of their technology into the BBx Generations.