public interface EsqlSqlcaHandler
Here is a sample class that intercepts the unique key violation error on PostgreSQL and maps it to the error code -803 so a program written for DB2 that checks if SQLCODE=-803 can work also on PostgreSQL:
import java.sql.SQLException;
import com.iscobol.types.CobolVar;
import com.iscobol.rts.EsqlSqlcaHandler;
public class ChangeSqlca implements EsqlSqlcaHandler {
public void sqlcaDecoder(SQLException ex, CobolVar sqlcode,
CobolVar sqlstate, CobolVar sqlerrmc) {
if (ex.getSQLState().equals("23505")) {
sqlcode.set(-803);
}
}
}
To install this class in your runtime session, you will set:
iscobol.esql.sqlca_handler=ChangeSqlca
| Modifier and Type | Method and Description |
|---|---|
void |
sqlcaDecoder(SQLException ex,
CobolVar sqlcode,
CobolVar sqlstate,
CobolVar sqlerrmc)
Receives the instance of SQLException behind an SQL error and allows you to set
the following SQLCA fields: SQLCODE, SQLERRMC and SQLSTATE.
|
void sqlcaDecoder(SQLException ex, CobolVar sqlcode, CobolVar sqlstate, CobolVar sqlerrmc)
ex - the Java exception produced by the SQL errorsqlcode - the value to be stored in SQLCODEsqlstate - the value to be stored in SQLSTATEsqlerrmc - the value to be stored in SQLERRMC