|
- Running the query
- Retrieving the query result
- INSERT query
- Managing text memos
- Managing binary memos
- SQL query (HExecuteSQLQuery or queries created in the query editor)
- Comparison with the syntax of HExecuteSQLQuery
- SQLExec and the threads
- Limitations in PHP
SQLExec (Function) In french: SQLExec Names and runs an SQL query. Caution: SQLExec does not start the process for retrieving the result in memory. The result is retrieved during the first call to one of the following functions: SQLFirst, SQLTable or SQLFetch. Remark: To handle a binary memo in a query, use the WDBinaryMemo keyword in the text of your query (see remarks for more details). Versions 16 and later New in version 16 Versions 19 and later New in version 19 Remark: From version 19, HFSQL is the new name of HyperFileSQL. Versions 21 and later New in version 21Syntax
Running an SQL query Hide the details
<Result> = SQLExec(<Text of SQL query> , <Name of the request>)
<Result>: Boolean - True if the query was executed,
- False otherwise. If the query was not run, the error message can be returned by the SQL.MesError variable once SQLInfo has been run.
<Text of SQL query>: Character string (with quotes) SQL code of query to run. <Name of the request>: Character string (with quotes) Name associated with the query text. Corresponds to:- the logical query name.
- the name and full path of query (".WDR" file).
Versions 16 and later New in version 16Remarks Running the query The information regarding the query execution is returned by SQLInfo. The SQL.NbCol variable contains the number of columns found in the query result. Once it was run and processed, the query must be freed by SQLClose. Retrieving the query result Then, the query result can be: - Transferred into a table or into a list box (SQLTable).
- Transferred into controls or variables (SQLAssociate).
- Retrieved line by line (SQLFetch).
SQLExec and the threads When running SQLExec in a secondary thread, the connection used must be established in the same thread: the connection cannot be established in the main thread (project or window). The connection established by SQLConnect is not shared in the other threads.
This page is also available for…
|
|
|
| |
| | ConnectionNum is int SourceName is string // Connection to a specific data source via ODBC MS ACCESS SourceName = "MS Access 97 Database" ConnectionNum = SQLConnect(SourceName, "", "", "", "ODBC") // <-------- IF ConnectionNum <> 0 THEN // The connection was successful
// Run the query and retrieve the result line by line i is int = 0 SQLExec("SELECT LASTNAME, FIRSTNAME, EXTENSION, PHOTO FROM CUSTOMER", "QRY1") // <-------- WHILE SQLFetch("QRY1") = 0 // There is still another line to read i++ // Retrieve the data LASTNAME[i] = SQLGetCol("QRY1", 1) FIRSTNAME[i] = SQLGetCol("QRY1", 2) EXTENSION[i] = SQLGetCol("QRY1", 3) {"IMAGE"+i} = SQLGetMemo("QRY1", 4) END SQLClose("QRY1")
ELSE // The connection failed: display an error message SQLInfo() Error("The connection to the data source " + SourceName + " failed." + CR + ... "Error code: " + SQL.Error + CR + SQL.MesError)
END // In any case (connection OK or not) SQLDisconnect() // <-------- |
|
|
|
| |
| |
| |
| |
| |
| |
| | |
| |