utPLSQL Installation - ORA-04047 error when exec ut.run(); - oracle

I am setting up utPL/SQL for my Oracle database, and everything seemed to installed correctly, but when I try to run the basic test runner, it gets an error: ORA-04047: object specified is incompatible with the flag specified
Problem
With a basic empty test package created, I run the line begin ut.run(); end; This gives me the following error:
Error starting at line : 1 in command -
BEGIN ut.run(); END;
Error report -
ORA-04047: object specified is incompatible with the flag specified
ORA-06512: at "UNIT_TEST_REPOS.UT_RUNNER", line 88
ORA-06512: at "UNIT_TEST_REPOS.UT_RUNNER", line 112
ORA-06512: at "UNIT_TEST_REPOS.UT", line 292
ORA-06512: at "UNIT_TEST_REPOS.UT", line 267
ORA-06512: at line 1
04047. 00000 - "object specified is incompatible with the flag specified"
*Cause: The object type implied by the flag does not match the type
of object specified.
*Action: Specify the correct object, or use the appropriate flag
What should happen is that it says the following:
Between string function
Finished in .451423 seconds
0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)
What I've done:
Using the installation guide here, I ran the windows script, created the schema for the test user by executing
create_utplsql_owner.sql, executed the install.sql script, and executed the create_synonyms_and_grants_for_public.sql. These were all the scripts that the installation guide said to execute. All seemed to have worked - I saw no errors. (Double checked the install.log file - no errors).
In the getting started tutorial for the utPLSQL documentation, I have created the (mostly empty) test package, exactly as stated in the header Create test package
create or replace package test_betwnstr as
-- %suite(Between string function)
end;
Context
I have limited experience working with Oracle. After some digging around, I got more context into what may cause the error -
it seems that it might be related to conflicting names, but I don't see what names would be conflicting. And again, this is just from a fresh install of utPLSQL, so it seems that something is mis-configured, but I don't know what...
I looked at the other questions, but they were related to insufficient user privileges.. I ran the scripts with an admin account (called CORE).
Version of utPL/SQL: 3.0.2
Version of Oracle: 11.2
Update 1
I looked into the lines of UT code that the error points to, and I saw the code at "UNIT_TEST_REPOS.UT", line 267 is the following: ut.run(ut_varchar2_list(sys_context('userenv', 'current_schema')), a_reporter, a_color_console, a_coverage_schemes, a_source_file_mappings, a_test_file_mappings, a_include_objects, a_exclude_objects );
So it seems that something is wrong with the user environment or current-schema set up? I looked-up the value of those (SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER') FROM DUAL;), and it returned CORE - the sys admin user name I was using to install the scripts.
Update 2
Sort of could get it to work... When I was initially running the command, I was connected as my default user CORE. I created a new connection as my UNIT_TEST_REPOS schema, and then I could get it to "work" by using the command select ut.run() from dual;, and it returned it as a table.
UNIT_TEST_REPOS.UT_VARCHAR2_ROWS('Finished in 0 seconds', '0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)', ' ')
This worked for my empty tests scenario, but when I continued the tutorial and added real test cases, it gave me the same result...
So, by connecting as a different schema, I could execute the code with no errors. But it cannot see the tests from the other user, so this is not a solution...
Update 3
Used SQLTools instead of SQL Developer to view the database, and it showed more details to the error message.
I also found information about the oracle error in a Google book Secrets of the Oracle Database and it had this segment:
If a name cannot be resolved in the specified context, "ORA-06564: object object_name does not exist" is raised, where object_name is the value of the parameter NAME passed to the procedure NAME_RESOLVE. If an existing object is resolved in the wrong context, the exception "ORA-04047: object specified is incompatible with the flag specified" is thrown. (bold emphasis mine)
Also, when I tried to execute the test script while in the UNIT_TEST_REPOS schema, and have it explicitly call the tests in my CORE schema,
begin ut.run('CORE'); end;
It got the same error as previously.
From what the book suggests, it sounds like there is an error with the flags that utPLSQL uses as part of its framework. But it looks the same as for the tutorials....

It would be great, if you could post such issues on the utPLSQL project directly.
https://github.com/utPLSQL/utPLSQL/issues
We're not able to follow stackoverflow, google groups and all other media.
The issue you've been facing should probably be resolved with utPLSQL v3.0.4.
It is Oracle namespace issue, when both object and schema are names the same way (from what I can see).

Not a solution, but a bypass.
If I make the package in the UNIT_TEST_REPOS, then it can see the tests and execute them. It seems like there is some configuration problem in the CORE schema that prevents utplsql from hooking properly. I used a separate schema and put the package there, and utPLSQL was able to run the tests that were there.
The actual solution would be to fix the configuration settings in the CORE so the utPLSQL object and flags can see each other properly. But I am not sure where to look.

Related

oracle apex Error handling function not working properly

I am trying to use the oracle's apex_error package to implement error handling in my app.
test app: https://apex.oracle.com/pls/apex/f?p=145329:2:11482099171656::NO:::
table created: constraint_lookup
function provided by oracle "apex_error_handling_example". https://docs.oracle.com/database/apex-18.1/AEAPI/Example-of-an-Error-Handling-Function.htm#AEAPI2216
The solution works fine except when you click on the error it gives error in console instead of taking you to the tab of the IR report.
Now click on the message so it should take you to the duplicate DeptID, but it just gives you error in the console.
I have tried to handle this at page level, application level also I tried to set the column_alias manually so I don't have to use the APEX_ERROR.AUTO_SET_ASSOCIATED_ITEM but all in vain.
Any help and your time will be much appreciated.

Oracle PL/SQL package errors (ORA-04063 and ORA-06508) when called from a java application

When I run my application and call a PL/SQL package, I get the errors:
ORA-04063: package body "SEARCH_TRAILER" has
errors ORA-06508: PL/SQL: could not find program unit being called:
"SEARCH_TRAILER" ORA-06512: at line 1
I replaced the package body and package spec and successfully recompiled yet I still get the error. There are other stored procedures called within this stored procedure. But if it was only of those stored procedures wouldn't the error call that stored procedure instead of the one that is called by the application?
Is there any thing I need to look at to resolve this error?
You need to find the compilation errors. If you're using an IDE like SQL Developer then there's a tab for that. If you're using SQL*Plus you should get the errors with the show errors command.
In any environment you can always run this:
select * from user_errors
where name = 'SEARCH_TRAILER'
(assuming you're connected as the package owner, otherwise use ALL_ERRORS).

Get SQL Plus to display more detailed errors

When installing my application, users must start SQL Plus and run an SQL script. This script contains creates many tables and many PL/SQL functions and triggers etc.
At the moment some of the functions are in the wrong order in the script and so users currently see a few "trigger created with compilation errors" type messages. I believe this is because the functions/triggers rely on other functions which means they cannot compile correctly.
What I would like to do is to find out which ones are failing and what the specific compilation error was instead of the rather vague warning I get at the moment. This way I can rearrange the functions in my install script and get no more warnings!
UPDATE
I would also like the specific errors to be logged into a file. At the moment I'm using the SPOOL command to log things, so it would be great if the errors could be 'spooled' too.
You can append show errors; after creation of procedures/triggers in order to see detailed error message.
You can add show err or select * from all_errors where name='<object_name>' order by sequence after each compilation command.

Oracle Error Has Occurred:ORA-20011: Execute_system: Error while receiving

After executing one package, i got the below error
Oracle Error Has Occurred:ORA-20011: Execute_system: Error while receiving.
Status = 1
Please let me know what the error means ,why the error occurs and how to rectify the same
Oracle has reserved the error numbers between ORA-20000 and ORA-20999 for us users. Which means that someone at your site has programmed their own user defined error. The package issues a RAISE_APPLICATION_ERROR(-20011,'Execute_system: Error while receiving.'); statement. Either directly in the package body or indirectly via a database trigger on one of the tables the package is modifying.
Regards,
Rob.

Synonym returning ORA-00904 error

I'm at my wits' end with this error.
I have a view which uses a function contained in a package in another schema. I've created a synonym to said package, and on my local dev DB, the view compiles correctly. On the build server, the view gives compilation errors.
When I run the select of the view manually, Oracle throws an ORA-00904 error on the synonym in the query. I just can't understand why it works in one place and not the other. The code on both servers is identical, as it's coming from our source control repository.
As phlogratos suggested, it was a privileges issue. As the user didn't have execute permissions on the package in the separate schema, it was causing this error.
The underlying problem was an issue with our script that applies grants, but it's good to know that references like this without permissions fail in this manner.

Resources