User Tools

Site Tools


prop_sqlrowset.htm
Navigation:  Language Reference > App C - PROP: Runtime Properties > Complete Property List >PROP:SQLRowSet Previous pageReturn to chapter overviewNext page

You can use property syntax (PROP:SQLRowSet) to execute SQL statements that return result sets in your program code by using PROP:SQLRowSet and naming the FILE or  backend VIEW defined in the Clarion Data Dictionary as the target within your program. This is only valid when using an SQL file driver (such as the ODBC, MS-SQL, or Oracle drivers). You can send any SQL statement supported by the SQL server that returns a result set.

After issuing the SQL statement, you use NEXT(file) to retrieve the result set one row at a time, into the file's record buffer. The FILE declaration receiving the result set must have at least as many fields as the SQL SELECT statement returns. If the Clarion ERRORCODE procedure returns 90, the FILEERRORCODE() and FILEERROR() functions return any error code and error message set by the back-end SQL server.

Example:

MySQLiteFile{PROP:SQLRowSet} = 'PRAGMA table_list'        ! get a list of tables in file

LOOP

NEXT(MySQLiteFile)

'

END

MySQLiteFile{PROP:SQLRowSet} = 'WITH q AS (SELECT COUNT(*) FROM f) SELECT * FROM q'

NEXT(MySQLiteFile)

The names used in the SQL statement are the SQL table names, not necessarily the same as the Clarion names you defined in the Dictionary.

See Also:Using Embedded SQL, PROP:SQL, FILEERRORCODE, FILEERROR

prop_sqlrowset.htm.txt · Last modified: 2021/04/15 15:57 (external edit)