Difference between revisions of "SQLPREPARE()"

From Recital Documentation Wiki
Jump to: navigation, search
 
(2 intermediate revisions by one user not shown)
Line 4: Line 4:
  
 
==Syntax==
 
==Syntax==
SQLPREPARE(<nStatementHandle>, <cSQLCommand>, [<cCursorName>])
+
SQLPREPARE(<nStatementHandle>, <cSQLCommand> [, <cCursorName>])
  
  
 
==See Also==
 
==See Also==
[[CREATE CONNECTION]], [[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLEXEC()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLSTRINGCONNECT()]], [[SQLTABLES()]]
+
[[CREATE CONNECTION]], [[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLERROR()]], [[SQLEXEC()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLSTRINGCONNECT()]], [[SQLTABLES()]]
  
  
Line 44: Line 44:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
nStatHand=SQLSTRINGCONNECT("rec@rec1:user1/pass1/usr/recital/uas/data/southwind.tcpip",.T.)
+
nStatHand=SQLSTRINGCONNECT("rec@rec1:user1/pass1-/usr/recital/uas/data/southwind.tcpip",.T.)
 
if nStatHand < 1
 
if nStatHand < 1
 
   messagebox('Cannot make connection', 16, 'SQL Connect Error')
 
   messagebox('Cannot make connection', 16, 'SQL Connect Error')
Line 56: Line 56:
 
endif
 
endif
 
</code>
 
</code>
 
  
 
==Products==
 
==Products==

Latest revision as of 16:15, 4 July 2011

Purpose

Prepare an SQL statement that will be executed by the SQLEXEC() function


Syntax

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


See Also

CREATE CONNECTION, SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLERROR(), SQLEXEC(), SQLGETPROP(), SQLMORERESULTS(), SQLROLLBACK(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES()


Description

The SQLPREPARE() function is used to prepare an SQL statement which will subsequently be executed by the SQLEXEC() function on the specified data source.

The SQLPREPARE() function operates on the data source specified by <nStatementHandle>.


Keywords Description
nStatementHandle The workarea in which the gateway data source is open.
cSQLCommand The SQL statement to be passed to the data source.
cCursorName The name of the cursor to use. If cCursorName is not specified, the default name SQLRESULT is used.


Return values:

Return Value Description
1 SQLPREPARE() successful
–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
  SQLPREPARE(nStatHand, "SELECT * FROM example WHERE account_no = ?myVar", "restab")
  SQLEXEC(nStatHand)
  browse
  SQLDISCONNECT(nStatHand)
endif

Products

Recital, Recital Server