Tag: Transaction does not have plain key test statement to_date error RAC
First, according to this article: http://www.cnblogs.com/coolzdp/p/7717332.html
We know that in the SELECT
*
stored ProcedureINTO 如果没有记录是不会往下执行的,直接抛出NO_DATA_FOUND异常,
This in plsql Developer Direct Test Execution No problem , will be reported ORA-1403 exception.
But it is not thrown when called in MyBatis.NO_DATA_FOUND异常,而是在select * into语句为空时默默的终止执行该过程。
There is a problem with transaction processing at the service layer, and the service layer calls the SELECT * into empty stored procedure logic must be faulty, should throw an exception to the controller layer,
Now it just terminates, and the subsequent statement executes, so it's not right.
My guess is that the MyBatis is NO_DATA_FOUND异常
filtered, and the catch is no longer thrown .
My approach is that if there is a select INTO, the Plsql process is finally manually captured NO_DATA_FOUND异常
, throwing a custom exception :
EXCEPTION when Then raise_application_error ('-20000'Select into did not find data ');
If it is the kind that needs to prompt the user to indicate why the select into must have a record, then honestly use the following statement:
SELECT COUNT(*) intoV_playvoyagecount fromPlan_voyageWHEREVessel_id_=P_vesselid andSailing_date_=To_date (P_saildate,'YYYY-MM-DD'); IFV_playvoyagecount= 0 ThenRaise_application_error (-20000,'No record'); END IF;
Refer to this article: https://www.cnblogs.com/zhangxsh/p/3494340.html
In fact, this article is not about calling stored procedures in MyBatis NO_DATA_FOUND异常
, but for
In select Fn_test (' 1 ') from dual; The call function in SQL returns NULL to terminate without NO_DATA_FOUND
throwing an exception.
The difference is that this is the processing of Oracle itself, the above is the processing of mybatis.
MyBatis call Oracle Stored procedure no_data_found exception handling analysis when select into is not logged