You can now type code that are for executing SQL statements.
Follow these steps:
/* To execute SQL (INSERT) query */ ret_code = SQLExecute(create_stmt.hstmt); ret_code = SQLRowCount(create_stmt.hstmt, &create_count); /* To execute SQL (SELECT) query */ ret_code = SQLExecute(read_stmt.hstmt); /* To execute SQL (UPDATE) query */ ret_code = SQLExecute(update_stmt.hstmt); ret_code = SQLRowCount(update_stmt.hstmt, &update_count);
/* To execute SQL (INSERT) query */
try {
…
create_count = create_cmd.ExecuteNonQuery();
…
} catch (Exception ex) { sql_ex = ex; }
/* To execute SQL (SELECT) query */
try {
…
read_rs = read_cmd.ExecuteQuery();
…
} catch (Exception ex) { sql_ex = ex; }
/* To execute SQL (UPDATE) query */
try {
…
update_count = update_cmd.ExecuteNonQuery();
…
} catch (Exception ex) { sql_ex = ex; }
/* To execute SQL (INSERT) query */
try {
…
create_cmd.execute();
create_count = hstmt_cmd.getUpdateCount();
…
} catch (Exception ex) { sql_ex = ex; }
/* To execute SQL (SELECT) query */
try {
…
read_cmd.execute();
read_rs = hstmt_cmd.getResultSet();
…
} catch (Exception ex) { sql_ex = ex; }
/* To execute SQL (UPDATE) query */
try {
…
update_cmd.execute();
update_count = hstmt_cmd.getUpdateCount();
…
} catch (Exception ex) { sql_ex = ex; }
The following predicates may be helpful in catching SQL errors:
ODBC_SUCCESSFUL(ret_code)
Globdata.GetDBMSData().GetDBMSManager().WasSuccessful(sql_ex)
globdata.getDBMSData().getDBMSManager().wasSuccessful(sql_ex)
ODBC_NOT_FOUND(ret_code)
Globdata.GetDBMSData().GetDBMSManager().WasNoDataFound(sql_ex)
globdata.getDBMSData().getDBMSManager().wasNoDataFound(sql_ex)
TiodbcDuplicate(&create_hstmt)
Globdata.GetDBMSData().GetDBMSManager().WasDuplicateFound(IefRuntimeParm2, “IEFDB”, sql_ex)
globdata.getDBMSData().getDBMSManager().wasDuplicateFound(“IEFDB”, sql_ex)
strcpy(globdata->psmgr_dasg_data.status_flag, fatal_error); strcpy(globdata->psmgr_dasg_data.last_status, db_error); TiodbcError(&create_stmt); longjmp(excp_jumpbuf, TRACE_EXCEPTION);
Globdata.GetErrorData().SetStatus(ErrorData.LastStatusFatalError); Globdata.GetErrorData().SetLastStatus(ErrorData.LastStatusDbError); Globdata.GetErrorData().SetErrorMessage(sql_ex); throw new ABException();
globdata.getErrorData().setStatus(ErrorData.FATAL_ERROR_FL_LS); globdata.getErrorData().setLastStatus(ErrorData.DB_ERROR_FL_LS); globdata.getErrorData().setErrorMessage(sql_ex); throw new ABException();
|
Copyright © 2014 CA.
All rights reserved.
|
|