Difference between revisions of "SQLERROR()"
From Lianjapedia
m (Text replace - "Recital" to "Lianja") |
Yvonne.milne (Talk | contribs) |
||
(11 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
− | Function to return the error message for the last | + | Function to return the error message for the last ODBC data connection error |
− | + | ||
==Syntax== | ==Syntax== | ||
SQLERROR(<nStatementHandle>) | SQLERROR(<nStatementHandle>) | ||
− | |||
==See Also== | ==See Also== | ||
− | + | [[SQLCANCEL()]], [[SQLCOLUMNS()]], [[SQLCOMMIT()]], [[SQLCONNECT()]], [[SQLDISCONNECT()]], [[SQLDATASOURCES()]], [[SQLDRIVERS()]], [[SQLEXEC()]], [[SQLGETPROP()]], [[SQLMORERESULTS()]], [[SQLPREPARE()]], [[SQLROLLBACK()]], [[SQLSETPROP()]], [[SQLSTRINGCONNECT()]], [[SQLTABLES()]], [[SQLTRANSACTION()]] | |
− | + | ||
==Description== | ==Description== | ||
− | The SQLERROR() function is used to return the error message for the last | + | The SQLERROR() function is used to return the error message for the last ODBC data connection error. |
− | The SQLERROR() function operates on the | + | The SQLERROR() function operates on the ODBC connection specified by <nStatementHandle>, which must be an active remote data connection handle. |
− | + | {| class="wikitable" width="100%" | |
− | {| class="wikitable" | + | !width="30%"|Keywords||width="70%"|Description |
− | !Keywords||Description | + | |
|- | |- | ||
− | |nStatementHandle|| | + | |nStatementHandle||Statement handle to the connection |
|- | |- | ||
|} | |} | ||
− | |||
====Return values:==== | ====Return values:==== | ||
The SQLERROR() function returns a character string containing the descriptive message for the last error. | The SQLERROR() function returns a character string containing the descriptive message for the last error. | ||
− | |||
==Example== | ==Example== | ||
<code lang="recital"> | <code lang="recital"> | ||
− | nStatHand= | + | nStatHand = sqlconnect("awhr") |
if nStatHand < 1 | if nStatHand < 1 | ||
− | + | messagebox("Cannot make connection", 16, "SQL Connect Error") | |
else | else | ||
− | + | messagebox("Connection made", 48, "SQL Connect Message") | |
− | + | sqlexec(nStatHand,"create table doc1 (account_no char(5), lastname char(25), balance dec(10,2))") | |
− | + | messagebox("Table created") | |
− | + | m_accno = "00699" | |
− | + | m_lastname = "Smith" | |
− | + | m_balance = 12345.67 | |
− | + | sqlexec(nStatHand,"insert into dbo.doc1 (account_no,lastname,balance) VALUES ('&m_accno','&m_lastname',&m_balance)") | |
− | + | messagebox("Record inserted") | |
− | + | nRet = sqlexec(nStatHand,"select * from dbo.doc1","mycursor") | |
+ | if nRet = -1 | ||
+ | messagebox(sqlerror(nstatHand)) | ||
+ | else | ||
+ | messagebox("Record selected") | ||
+ | list | ||
+ | endif | ||
+ | // Using prepared statement | ||
+ | sqlprepare(nStatHand,"select * from dbo.doc1 where account_no = ?m_accno","mycursor") | ||
+ | nRet = sqlexec(nStatHand) | ||
+ | if nRet < 1 | ||
+ | messagebox(sqlerror(nstatHand)) | ||
+ | else | ||
+ | messagebox("Record selected using prepared statement") | ||
+ | list | ||
+ | endif | ||
+ | sqldisconnect(nStatHand) | ||
endif | endif | ||
</code> | </code> | ||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
− | |||
[[Category:ODBC Functions]] | [[Category:ODBC Functions]] | ||
[[Category:SQL Functions]] | [[Category:SQL Functions]] |
Latest revision as of 07:46, 4 March 2019
Purpose
Function to return the error message for the last ODBC data connection error
Syntax
SQLERROR(<nStatementHandle>)
See Also
SQLCANCEL(), SQLCOLUMNS(), SQLCOMMIT(), SQLCONNECT(), SQLDISCONNECT(), SQLDATASOURCES(), SQLDRIVERS(), SQLEXEC(), SQLGETPROP(), SQLMORERESULTS(), SQLPREPARE(), SQLROLLBACK(), SQLSETPROP(), SQLSTRINGCONNECT(), SQLTABLES(), SQLTRANSACTION()
Description
The SQLERROR() function is used to return the error message for the last ODBC data connection error.
The SQLERROR() function operates on the ODBC connection specified by <nStatementHandle>, which must be an active remote data connection handle.
Keywords | Description |
---|---|
nStatementHandle | Statement handle to the connection |
Return values:
The SQLERROR() function returns a character string containing the descriptive message for the last error.
Example
nStatHand = sqlconnect("awhr") if nStatHand < 1 messagebox("Cannot make connection", 16, "SQL Connect Error") else messagebox("Connection made", 48, "SQL Connect Message") sqlexec(nStatHand,"create table doc1 (account_no char(5), lastname char(25), balance dec(10,2))") messagebox("Table created") m_accno = "00699" m_lastname = "Smith" m_balance = 12345.67 sqlexec(nStatHand,"insert into dbo.doc1 (account_no,lastname,balance) VALUES ('&m_accno','&m_lastname',&m_balance)") messagebox("Record inserted") nRet = sqlexec(nStatHand,"select * from dbo.doc1","mycursor") if nRet = -1 messagebox(sqlerror(nstatHand)) else messagebox("Record selected") list endif // Using prepared statement sqlprepare(nStatHand,"select * from dbo.doc1 where account_no = ?m_accno","mycursor") nRet = sqlexec(nStatHand) if nRet < 1 messagebox(sqlerror(nstatHand)) else messagebox("Record selected using prepared statement") list endif sqldisconnect(nStatHand) endif