ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / SQL functions
  • Current row in the query
  • Query columns
  • Query without result
  • Using tabulations in the items
  • SQLCol and SQLGetCol functions
  • Retrieving Float items on Oracle (via ODBC)
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Retrieves the content of the specified column from the query result, for the current line.
Caution: This function must be used during a "SQLFetch/SQLGetCol" browse of the query result. For more details, see Types of SQL browse.
WEBDEV - Browser code The SQL functions are used to handle the local databases (such as Web SQL databases). Only the SQLFetch/SQLGetCol browse mode is available. For more details, see Accessing a database in local mode (SQLite).
Example
i is int = 0
SQLExec("SELECT LASTNAME, FIRSTNAME, EXTENSION, PHOTO FROM CUSTOMER", "QRY1")
// Retrieve the query row by row
WHILE SQLFetch("QRY1") = 0 // There is another line to read
i++
// Retrieve the data
LASTNAME[i] = SQLGetCol("QRY1", 1)
FIRSTNAME[i] = SQLGetCol("QRY1", 2)
EXTENSION[i] = SQLGetCol("QRY1", 3)
END
SQLClose("QRY1")
Syntax
<Result> = SQLGetCol(<Query name> , <Column number>)
<Result>: Character string
Value of the column.
<Query name>: Character string
Name of the query created and executed with SQLExec, or executed with SQLExecWDR.
Java The queries created in the query editor must be specified in the format of a character string.
WEBDEV - Browser code Only the queries created and run by SQLExec are available.
<Column number>: Integer
Number of the column to retrieve. This column corresponds to a query column (and not to a table column). If several columns must be retrieved, the subscript of the columns must be specified in ascending order. For example, you must do SQLCol("QRY1", 1) then SQLCol("QRY1", 2).
WEBDEV - Browser codeJava The columns can be retrieved in any order.
Remarks

Current row in the query

The current line is positioned by SQLFetch.

Query columns

  • To read memo columns, use SQLGetMemo. To read the text memo columns, use SQLGetTextMemo.
    PHP SQLGetMemo and SQLGetTextMemo are useless.
    WEBDEV - Browser code The memo columns cannot be read.
  • The number of columns found in the query result is returned by the SQL.NbCol variable (assigned by SQLInfo).
  • If the column is a numeric column, SQLGetCol converts the result to a string. However, in WLanguage, you can assign the result returned by SQLGetCol in a numeric variable. WLanguage automatically performs the conversion.
  • Columns have to be retrieved in ascending order.
    WEBDEV - Browser codeJava The columns can be retrieved in any order.
  • The same column cannot be retrieved several times in a row. Indeed, the second time, the result will be an empty string.
    WEBDEV - Browser code The same column can be retrieved several times in a row.
  • SQLGetCol cannot be used to retrieve the binary strings.

Query without result

SQLGetCol should not be called if the query did not return a result: the SQL.Out variable must be tested once the position has been set in the query result, before calling SQLGetCol.
For example:
// Retrieve the value of the 1st column for the 1st record
Value is string
QueryText is string
QueryText = "SELECT CUSTNAME, ADDR1, ADDR2, CITY, ZIP FROM INV"
SQLExec(QueryText, "QRY1")
Value = SQLGetCol("QRY1", 1)

Using tabulations in the items

The SQL functions are used to insert tabulations into the file items.
To get the value of the items (with Tabs), use SQLFetch/SQLGetCol.
Example: SQLGetCol and tabs in items
The items of the records to retrieve are as follows:
Item 1Item 2
Record 1JohnSmith
Record 2John + tab + MacDoughnut
For the first record:
  • SQLGetCol(QRY, 1): retrieves John
  • SQLGetCol(QRY, 2): retrieves Smith
For the second record:
  • SQLGetCol(QRY,1 ): retrieves John + tab + Mac
  • SQLGetCol(QRY, 2): retrieves Doughnut
WINDEVWEBDEV - Server codeReports and QueriesWindowsJavaUser code (UMC)PHPAjaxHFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DB

SQLCol and SQLGetCol functions

SQLCol and SQLGetCol are equivalent when accessing data via OLE DB or HFSQL. However, you must respect the type of browse associated with each one of these functions:
  • SQLCol function: "SQLFirst/SQLCol" browse.
  • SQLGetCol function: "SQLFetch/SQLGetCol" browse.
For more details, see Types of SQL browse.
WINDEVWEBDEV - Server codeReports and QueriesWindowsJavaUser code (UMC)PHPAjaxODBC

Retrieving Float items on Oracle (via ODBC)

By default, the decimal separator used for the Float items on Oracle is the dot. However, the ODBC driver returns the value by using the comma as decimal separator. The decimal places are lost when the value is assigned to a numeric control.
To avoid this problem, you must configure the decimal separator for the current connection:
// Connection to the Oracle database
SQLConnect("MyOracleDatabase", "User", "Pass", "", "ODBC")
// Request for changing the decimal separator
SQLExec("ALTER SESSION SET NLS_NUMERIC_CHARACTERS ='. '", "TempQry")
Component: wd290hf.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/06/2023

Send a report | Local help