Closed Andreas741 closed 1 year ago
Hi,
Shall the host API user (OCILIB) consider a PL/SQL statement execution returning OCI_NO_DATA as an error case? That's a good question. Other PL/SQL exceptions are mapped to OCI_ERROR while 'no data found' is mapped to OCI_NO_DATA. In Oracle OCI, OCI_NO_DATA is not an error in-fine. For example, executing a select from a table that returns zero rows also returns OCI_NO_DATA. Like also when fetching the last row. In these cases, OCI_NO_DATA is not an error. Thus making a special case for some PL/SQL executions is not hat trivial (how to identify them) and could lead to some regression. It is not as straightforward as it could seem. Let me think about it.
Regards,
Vincent
Hello, many thanks for the quick response
I think a no_data_found exception must be thrown because otherwise an error occurs without the user noticing. If a no_data_found exception should be ignored, you can build an exception handler in the PL/SQL block or use a cursor. The normal behavior in PL/SQL is that an exception is thrown if no data was found when selecting into, I think the behavior in ocilib should be identical. This would also make it much easier to migrate from other Oracle interfaces to ocilib.
I know it's not easy to do the right thing, especially in this case select function(abc) from table ... It is possible that no records are found which is not an error or a no_data_found exception may occur in the function() function which is an error.
Greetings from Germany
Hi,
I committed a change in v4.7.5 branch that handles no_data_found from PL/SQL engine as an error while treating no_data_found from SQL engine as a success.
Regards,
Vincent
Thank you!
Hello,
I think I found a bug in ocilib 4.7.4. The problem also occurred in ocilib 4.5.1. A no data found exception in a pl/sql block is not thrown.
Kind regards
OcilibTest2.sql
// OcilibTest2.cpp
My temporary fix in file statement.c line 1414: