VS:DBSQLExecuteError: Difference between revisions
m (1 revision) |
No edit summary |
||
Line 25: | Line 25: | ||
message | message | ||
DYNARRAY[] of CHAR | DYNARRAY[] of CHAR | ||
This is the message text. | |||
</line> | </line> | ||
<line> | <line> | ||
state | state | ||
DYNARRAY[] of CHAR | DYNARRAY[] of CHAR | ||
The state provides detailed information about the cause of a warning or error. | |||
</line> | </line> | ||
<line> | <line> | ||
code | code | ||
LONGINT | LONGINT | ||
This is the native error number. | |||
</line> | </line> | ||
<line> | <line> | ||
internalDesc | internalDesc | ||
DYNARRAY[] of CHAR | DYNARRAY[] of CHAR | ||
It is not in use. | |||
</line> | </line> | ||
</lineList> | </lineList> | ||
Line 46: | Line 46: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark></remark> | <remark> | ||
The '''message text''' is the text of the diagnostic. | |||
The '''state''' is a five character SQLSTATE code. The first two characters indicate the class and the next three indicate the subclass. SQLSTATEs provide detailed information about the cause of a warning or error. For a complete list of states see [http://msdn.microsoft.com/en-us/library/ms714687%28v=vs.85%29.aspx Appendix A: ODBC Error Codes]. A list of ODBC 2.x to ODBC 3.x SQLSTATE mappings can be found [http://msdn.microsoft.com/en-us/library/ms712451.aspx here]. | |||
The '''native error code''' is a code specific to the data source. This number is often extremely useful to the driver developers in locating an internal error or state. If you are reporting a bug for which you obtained an error you should always quote the ODBC function called, the error text and this native number. | |||
Example of ODBC error reported by Vectorwroks and occured in FileMaker driver: | |||
''[65535] Driver error: 08S01 | |||
[FileMaker][FileMaker] Failed to connect to listener (2)'' | |||
'''NB! However, there is no guarantee that all drivers return them.''' | |||
</remark> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<sample></sample> | <sample> | ||
==== VectorScript ==== | |||
<code lang="pas"> | |||
PROCEDURE Test; | |||
VAR | |||
ok : BOOLEAN; | |||
message, state, internalDesc : DYNARRAY[] OF CHAR; | |||
code, colCnt, resSetInst : LONGINT; | |||
begin | |||
ok := DBDocAddConn( 'MyTestODBCDatabase', '', '' ); | |||
ok := DBSQLExecuteDSN( 'MyTestODBCDatabase', '', '', 'SELECT * FROM Spaces', colCnt, resSetInst ); | |||
if not ok then | |||
begin | |||
ok := DBSQLExecuteError(message, state, code, internalDesc); | |||
AlrtDialog(Concat('state: ', state, Chr(13), 'message: ', message, Chr(13), 'code: ', code, Chr(13), 'intDesc: ', internalDesc)); | |||
end; | |||
end; | |||
RUN(Test); | |||
</code> | |||
==== Python ==== | |||
<code lang="py"> | |||
import vs | |||
ok = vs.DBDocAddConn( 'MyTestODBCDatabase', '', '' ) | |||
colCnt = 0 | |||
resSetInst = 0 | |||
ok = vs.DBSQLExecuteDSN( 'MyTestODBCDatabase', '', '', 'SELECT * FROM Spaces', colCnt, resSetInst ) | |||
ok, message, state, code, internalDesc = vs.DBSQLExecuteError() | |||
vs.AlrtDialog('state: ' + state + '\nmessage: ' + message + '\ncode: ' + str(code) + '\nintDesc: ' + internalDesc) | |||
</code> | |||
</sample> | |||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
Latest revision as of 15:23, 6 November 2014
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Return information about the last error occured in the ODBC API functions.
FUNCTION DBSQLExecuteError(
VAR message :DYNARRAY[] of CHAR;
VAR state :DYNARRAY[] of CHAR;
VAR code :LONGINT;
VAR internalDesc :DYNARRAY[] of CHAR) : BOOLEAN;
def vs.DBSQLExecuteError(): return (BOOLEAN, message, state, code, internalDesc)
Parameters
message DYNARRAY[] of CHAR This is the message text. state DYNARRAY[] of CHAR The state provides detailed information about the cause of a warning or error. code LONGINT This is the native error number. internalDesc DYNARRAY[] of CHAR It is not in use.
Remarks
The message text is the text of the diagnostic.
The state is a five character SQLSTATE code. The first two characters indicate the class and the next three indicate the subclass. SQLSTATEs provide detailed information about the cause of a warning or error. For a complete list of states see Appendix A: ODBC Error Codes. A list of ODBC 2.x to ODBC 3.x SQLSTATE mappings can be found here.
The native error code is a code specific to the data source. This number is often extremely useful to the driver developers in locating an internal error or state. If you are reporting a bug for which you obtained an error you should always quote the ODBC function called, the error text and this native number.
Example of ODBC error reported by Vectorwroks and occured in FileMaker driver: [65535] Driver error: 08S01 [FileMaker][FileMaker] Failed to connect to listener (2)
NB! However, there is no guarantee that all drivers return them.
Example
VectorScript
PROCEDURE Test; VAR ok : BOOLEAN; message, state, internalDesc : DYNARRAY[] OF CHAR; code, colCnt, resSetInst : LONGINT; begin ok := DBDocAddConn( 'MyTestODBCDatabase', '', '' ); ok := DBSQLExecuteDSN( 'MyTestODBCDatabase', '', '', 'SELECT * FROM Spaces', colCnt, resSetInst ); if not ok then begin ok := DBSQLExecuteError(message, state, code, internalDesc); AlrtDialog(Concat('state: ', state, Chr(13), 'message: ', message, Chr(13), 'code: ', code, Chr(13), 'intDesc: ', internalDesc)); end; end; RUN(Test);
Python
import vs ok = vs.DBDocAddConn( 'MyTestODBCDatabase', '', '' ) colCnt = 0 resSetInst = 0 ok = vs.DBSQLExecuteDSN( 'MyTestODBCDatabase', '', '', 'SELECT * FROM Spaces', colCnt, resSetInst ) ok, message, state, code, internalDesc = vs.DBSQLExecuteError() vs.AlrtDialog('state: ' + state + '\nmessage: ' + message + '\ncode: ' + str(code) + '\nintDesc: ' + internalDesc)
Version
Availability: from Vectorworks 2012