Difference between revisions of "SQLEXEC()"

From Lianjapedia
Jump to: navigation, search
m (1 revision: SQL)
Line 1: Line 1:
 
==Purpose==
 
==Purpose==
 
Send an SQL statement to a data source
 
Send an SQL statement to a data source
 
  
 
==Syntax==
 
==Syntax==
 
SQLEXEC(<nStatementHandle> [, <cSQLCommand> [, <cCursorName>]])
 
SQLEXEC(<nStatementHandle> [, <cSQLCommand> [, <cCursorName>]])
 
  
 
==See Also==
 
==See Also==
[[CREATE CONNECTION]], [[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLERROR()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLPREPARE()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLSTRINGCONNECT()]], [[SQLTABLES()]]
+
[[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLERROR()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLPREPARE()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLSTRINGCONNECT()]], [[SQLTABLES()]]
 
+
  
 
==Description==
 
==Description==
Line 15: Line 12:
  
 
The SQLEXEC() function operates on the data source specified by <nStatementHandle>.  The [[SQLERROR()]] function can be used to return the error message if the SQL statement fails.
 
The SQLEXEC() function operates on the data source specified by <nStatementHandle>.  The [[SQLERROR()]] function can be used to return the error message if the SQL statement fails.
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 27: Line 23:
 
|-
 
|-
 
|}
 
|}
 
  
 
====Return values:====
 
====Return values:====
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 44: Line 38:
 
|-
 
|-
 
|}
 
|}
 
  
 
==Example==
 
==Example==
Line 60: Line 53:
 
</code>
 
</code>
  
==Products==
 
Recital, Recital Server
 
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:SQL]]
 
[[Category:SQL]]
 
[[Category:Remote Data Connectivity Functions]]
 
[[Category:Remote Data Connectivity Functions]]

Revision as of 06:27, 22 March 2012

Purpose

Send an SQL statement to a data source

Syntax

SQLEXEC(<nStatementHandle> [, <cSQLCommand> [, <cCursorName>]])

See Also

SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLERROR(), SQLGETPROP(), SQLMORERESULTS(), SQLPREPARE(), SQLROLLBACK(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES()

Description

The SQLEXEC() function is used to send an SQL statement to the specified data source.

The SQLEXEC() function operates on the data source specified by <nStatementHandle>. The SQLERROR() function can be used to return the error message if the SQL statement fails.

Keywords Description
nStatementHandle The workarea in which the gateway data source is open.
cSQLCommand The SQL statement to be passed to the data source. The cSQLCommand can be omitted if the SQL statement has already been set up using SQLPREPARE().
cCursorName The name of the temporary table to use. If cCursorName is not specified, the default name SQLRESULT is used. If the SQLEXEC() is running a pre-prepared statement, the cCursorName is taken from the SQLPREPARE() setting.

Return values:

Return Value Description
<n> Number of results sets if more than 1
0 SQLEXEC() is still executing
1 SQLEXEC() finished executing
-1 Connection error

Example

nStatHand=SQLSTRINGCONNECT("rec@rec1:user1/pass1-/usr/recital/uas/data/southwind.tcpip",.T.)
if nStatHand < 1
    messagebox("Cannot make connection", 16, "SQL Connect Error")
else
    messagebox('Connection made', 48, 'SQL Connect Message')
    store "00010" to myVar
    SQLEXEC(nStatHand, "SELECT * FROM example WHERE account_no = ?myVar", "restab")
    browse
    SQLDISCONNECT(nStatHand)
endif