AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Administrar bases de datos / Funciones SQL
  • 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
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Retrieves the content of the specified column from the query result, for the current line.
Warning This function must be used when browsing the result of a query of type "SQLFetch/SQLGetCol". For more details, see Types of SQL browse.
WEBDEV - Código Navegador 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).
Ejemplo
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")
Sintaxis
<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 - Código Navegador 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 index of the columns must be specified in ascending order. For example, you must do SQLCol("QRY1", 1) then SQLCol("QRY1", 2).
WEBDEV - Código NavegadorJava Columns can be retrieved in any order.
Observaciones

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 - Código Navegador 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 - Código NavegadorJava Columns can be retrieved in any order.
  • The same column cannot be retrieved several times in a row. The second time it is retrieved, the result is an empty string.
    WEBDEV - Código Navegador The same column can be retrieved several times in a row.
  • SQLGetCol doesn't get binary strings.

Query without result

The function SQLGetCol FUNCTION function must not be called if the query has not returned any results: you must test the SQL.Outside variable after positioning yourself in the query result and before calling the SQLGetCol FUNCTION.
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(REQ, 1): retrieves John
  • SQLGetCol(REQ, 2): retrieves Smith
For the second record:
  • SQLGetCol(REQ,1 ): retrieves John + tab + Mac
  • SQLGetCol(REQ, 2): retrieves Doughnut
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsJavaCódigo de Usuario (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:
  • Function SQLCol: "SQLFirst/SQLCol" type path.
  • Function SQLGetCol: type path "SQLAvance/SQLLitCol".
For more details, see Types of SQL browse.
WINDEVWEBDEV - Código ServidorReportes y ConsultasWindowsJavaCódigo de Usuario (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")
Componente: wd300hf.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local