Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Retrieves the error code returned by the SQL database backend for the last SQL operation.
Syntax
public int getLastError()
Run On
Called
Return Value
Type: int
The error code returned by the SQL database backend for the last SQL operation; or 0 for success.
Examples
static void StatementGetLastError()
{
str sql, sql2;
UserConnection Connection = new UserConnection();
Statement Statement = Connection.createStatement();
boolean clear_infolog = false;
print "-Delete-a-non-existing-record-(valid statement)-----------";
sql = "delete from zipcode where Recid = 2";
new SqlStatementExecutePermission(sql).assert();
Statement.executeUpdate(sql);
print " Error code was: ", Statement.getLastError();
print " Error message was '", Statement.getLastErrorText(), "'";
try
{
print "\n";
print "-Delete-from-a-non-existing-table-(invalid statement)--- --";
sql2 = "delete from StrangeTable07";
new SqlStatementExecutePermission(sql2).assert();
Statement.executeUpdate(sql2);
}
catch (exception::Error)
{
print "Exception was caught:";
print " Error code was: ", Statement.getLastError();
print " Error message was '", Statement.getLastErrorText(), "'";
}
CodeAccessPermission::revertAssert();
pause;
}