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
  • Running the query
  • Retrieving the query result
  • INSERT query
  • Managing text memos
  • Managing binary memos
  • SQL query (SQLExec or queries created in the query editor)
  • Comparison with the syntax of HExecuteSQLQuery
  • SQLExec and threads
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
Names and runs an SQL query.
Attention The function SQLExec function does not start the memory result retrieval process. The result is retrieved on the first call to one of the following functions: SQLFirst, SQLTable or SQLFetch.
Note To manipulate a binary memo in a query, use the keyword WDMemoBinary keyword in your query text (for details, see remarks).
WINDEVCódigo de Usuario (UMC)HFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBODBCConectores Nativos
// Connect to the database
// (SQLConnect or SQLConnectWS functions)

// 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")

// Disconnect (SQLDisconnect)
Sintaxis

Running an SQL query Ocultar los detalles

<Result> = SQLExec(<SQL query text> , <Query name>)
<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.
<SQL query text>: Character string
SQL code of query to run.
<Query name>: Character string
Name associated with the query text. Corresponds to:
  • the logical query name.
  • the name and full path of query (".WDR" file).
Java The query name corresponds to the logical query name only.
Observaciones

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).
WINDEVCódigo de Usuario (UMC)HFSQL ClassicHFSQL Client/Server

INSERT query

When running an INSERT query, the SQL.IDAuto variable contains the automatic identifier that was added during the previous INSERT.
WINDEVCódigo de Usuario (UMC)HFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBODBCConectores Nativos

Managing text memos

In the <Query text> parameter, a text memo is used like a text variable. For example:
// Query with condition on a text memo whose value is "Good customer" 
QueryText = "SELECT CUSTNAME FROM CUSTOMER WHERE CUSTOMERMEMO = 'Good customer'"
SQLExec(QueryText, "QRY1")
WINDEVJavaCódigo de Usuario (UMC)ODBCConectores Nativos

Managing binary memos

To write a binary memo in a table (using an SQL UPDATE or INSERT command), the following syntax must be used in the text of the query:
  • {WDBinaryMemo('<FileName>' [, 'File'])}

    where:
    • File (default value) indicates that the memo is a binary memo (coming from a file).
    • WDBinaryMemo is a reserved word.
    • <FileName> is the physical name of a file.
  • {WDBinaryMemo('<FileName>' [, 'TextFile'])}
    where:
    • TextFile indicates that the memo is a text memo (coming from a file).
    • WDBinaryMemo is a reserved word.
    • <FileName> is the physical name of a file.
For example:
// Insert the C:\PHOTO\SMITH.BMP file into a binary memo
QueryText = "INSERT INTO CUSTOMER VALUES ('SMITH', 'John'," + ... 
	"{WDBinaryMemo('C:\PHOTO\SMITH.BMP')})"
SQLExec(QueryText, "QRY1")
// Insert the C:\DOC\LETTER.TXT file into a text memo
QueryText = "INSERT INTO CUSTOMER VALUES ('THOMPSON', 'Christopher'," + ... 
	"{WDBinaryMemo('C:\DOC\LETTER.TXT', 'TextFile')})"
SQLExec(QueryText, "QRY1")

Note Inserting binary memos into an HFSQL data file using SQL functions is not possible and will result in an error. The error message is as follows: "Query cannot be initialized. Character {WDMemBinary( unexpected".
WINDEVCódigo de Usuario (UMC)HFSQL ClassicHFSQL Client/ServerHyper File 5.5

SQL query (SQLExec or queries created in the query editor)

When using the SQL DELETE, INSERT or UPDATE statements, no integrity check and no duplicate check are performed on an HFSQL database. This feature is not available in this version.
Solution: Use HFSQL functions (HDelete, HAdd or HModify) on your data files. The integrity check and the duplicate check will be automatically performed.
Remarque: The HExecuteQuery and HExecuteSQLQuery functions are used to check the integrity and duplicates of an HFSQL database.
WINDEVJavaCódigo de Usuario (UMC)HFSQL ClassicHFSQL Client/ServerHyper File 5.5OLE DBODBCConectores Nativos

Comparison with the syntax of HExecuteSQLQuery

HExecuteSQLQuery can also be used to run an SQL query. The parameters of these two functions are identical, but their order is Reverse: the HExecuteSQLQuery function specifies the query name first, followed by the query text (using the same standard as all HFSQL functions).
The syntax of SQLExec is kept for backward compatibility.

SQLExec and threads

When executing the SQLExec FUNCTION in a secondary thread, the connection used must be made in the same thread: the connection cannot be made in the main thread (project or window). The connection established by SQLConnect is not shared in the other threads.
Componente: wd300hf.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Exemplo de conexao em Postgresql em outra porta
nDBConnection = SQLConnect(sServerIP,sUser,sPassword,sDBName,"PostgreSQL","","Server Port = 15433")
Boller
12 04 2023

Última modificación: 27/03/2025

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