User Tools

Site Tools


where_1.htm
Navigation:  SQL Driver Strings(General) >====== WHERE (SQL Driver String) ====== Previous pageReturn to chapter overviewNext page

[ Where“ = ] SEND (file, '/WHERE [ where-clause ]' )

blk2blue.jpg

The SQL Accelerator drivers automatically build SQL WHERE clauses when your Clarion code contains a SET followed by a NEXT or PREVIOUS. You can customize the driver generated WHERE clause by using the WHERE driver string. You can also set the WHERE driver string at runtime with the use of PROP:WHERE. PROP:WHERE is a write-only property.

The SEND must be executed after the SET statement and before the NEXT or PREVIOUS statement.

NoteBox.jpg

The SET statement clears any WHERE clause set by the SEND statement.

Because the SQL driver's generated SELECT statement is not compiled until the NEXT or PREVIOUS statement, the SEND function posts no error code and returns no result. For example:

Orders  FILE,PRE(Ord),DRIVER('ODBC'),NAME('Ord')

NameDate KEY(+Ord:NameId,-Ord:Date)

Record   RECORD

Name      STRING(12),NAME('NameId')

Date      DATE,NAME('OrderDate')

Type      STRING(1),NAME('OrderType')

Details   STRING(20),NAME('OrderDetails')

        END

       END

 CODE

Ord:Name = 'SMITH'

SET(Ord:NameDate,Ord:NameDate)

SEND(Orders, '/WHERE OrderType = “M”')

LOOP

   NEXT(Orders)

   !…some processing

END

This generates a SELECT statement similar to:

SELECT NameId,OrderDate,OrderType,OrderDetails FROM Orders

 WHERE (NameID >= 'SMITH') AND (OrderType = 'M')

where_1.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1