Reputation: 345
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
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)
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;
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
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.
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...
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....
Upvotes: 3
Views: 1281
Reputation: 101
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).
Upvotes: 1
Reputation: 345
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.
Upvotes: 0