Home > database >  Oracle stored in the process of the EXECUTE IMMEDIATE execution result is empty when how to continue
Oracle stored in the process of the EXECUTE IMMEDIATE execution result is empty when how to continue

Time:10-25

Oracle stored in the process of the EXECUTE IMMEDIATE execution result is empty when how to continue?
The EXECUTE IMMEDIATE P_SQL_QUERY INTO P_NUM;
P_SQL_QUERY inside is select count (1) the from t
P_num definition is number type, now stored procedure execution error, because the results of the P_SQL_QUERY is null, don't know how to deal with now, in fact, I just want P_SQL_QUERY results is not empty, but as a result of the free, cause an error cannot continue, great god, please give directions!!!!!!

CodePudding user response:

The count without data is 0, there is having it behind you

CodePudding user response:

P_SQL_QUERY there are group by, if there is one and the free field value is null, the proposal first behind the where the null first filtered out

CodePudding user response:

reference 1st floor ZJHZ_ leaf response:
count without data is 0, behind you have having

Did not having that judging table data, and then INTO the variable, for subsequent operations, it is correct if there is no data to the table here the EXECUTE IMMEDIATE P_SQL_QUERY INTO P_NUM;

CodePudding user response:

refer to the second floor Mricoo_ weeks response:
is there any group by P_SQL_QUERY inside, if there is one and the free field value is null, suggest first behind the where the first null to filter out

There is no group, no, only a count (1) if there is a data query for each table in the database

CodePudding user response:

Know how to deal with

CodePudding user response:

Dynamic SQL now that no matter how is not empty, then the code more step judgment, if is empty, will P_SQL_QUERY assignment for a meaningless executable SQL, follow-up on this case p_num multiple judgment can also,

CodePudding user response:

Two schemes:
1, with the NVL, will be treated as NULL, you need to value,
2, and add exception handling to ensure that code even if wrong, also can continue execution, don't let it drop.
  • Related