我設立utPL/SQL我的Oracle數據庫,一切似乎正確安裝,但是當我嘗試運行基本的測試運行,它會得到一個錯誤:ORA-04047: object specified is incompatible with the flag specified
utPLSQL安裝 - 執行ut.run()時出現ORA-04047錯誤;
問題
有了一個基本的創建空的測試包,我跑行begin ut.run(); end;
這使我有以下錯誤:
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
應該發生的是,它說以下內容:
Between string function
Finished in .451423 seconds
0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)
我做了什麼:
- 使用the installation guide here,我跑了Windows腳本,通過執行
create_utplsql_owner.sql
創建的測試用戶的模式,執行install.sql
腳本,執行create_synonyms_and_grants_for_public.sql
。這些都是安裝指南要求執行的所有腳本。一切似乎都奏效了 - 我沒有看到任何錯誤。 (雙重檢查了install.log文件 - 沒有錯誤)。 在getting started tutorial爲utPLSQL文檔,我已經創建了(大部分是空的)測試包,正如在標題說明創建測試包
create or replace package test_betwnstr as -- %suite(Between string function) end;
語境
我與Oracle合作經驗有限。在digging around之後,我得到了更多可能導致錯誤的上下文 - 它似乎可能與衝突的名稱有關,但我沒有看到哪些名稱會衝突。再次,這只是從一個全新的utPLSQL安裝,所以它似乎有些東西是錯誤配置,但我不知道是什麼...
我看了其他問題,但他們有關不足用戶權限..我用管理員帳戶(稱爲CORE)運行腳本。 utPL/SQL的
版本:3.0.2
的Oracle版本:11.2
更新1
我看着那個錯誤指向,我看到的UT代碼行代碼在「UNIT_TEST_REPOS.UT」,第267行是以下內容: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);
所以看起來有什麼不對user environment
或current-schema
設置?我查找了那些(SELECT SYS_CONTEXT ('USERENV', 'SESSION_USER') FROM DUAL;
)的值,並且它返回了CORE - 我用來安裝腳本的sys admin用戶名。
更新2
排序可以得到它的工作...當我最初運行的命令,我連我的默認用戶CORE。我創建了一個新的連接作爲我的UNIT_TEST_REPOS模式,然後我可以通過使用命令select ut.run() from dual;
使它「工作」,並將它作爲表返回。
UNIT_TEST_REPOS.UT_VARCHAR2_ROWS('Finished in 0 seconds', '0 tests, 0 failed, 0 errored, 0 disabled, 0 warning(s)', ' ')
這個工作對我的空試驗的情況,但是當我繼續教程,並添加實際測試的情況下,它給了我同樣的結果...
所以,通過連接爲一個不同的模式,我可以沒有錯誤地執行代碼。但它不能看到其他用戶的測試,所以這不是一個解決方案...
更新3
使用SQLTools而不是SQL Developer來查看數據庫,並表現出更多的細節錯誤信息。
我也發現有關Oracle錯誤信息在谷歌圖書Oracle數據庫的祕密,它有這一段:
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)
此外,當我試圖執行測試腳本,而在在UNIT_TEST_REPOS模式,並將其顯式調用測試在我的核心架構,
begin ut.run('CORE'); end;
它得到了同樣的錯誤之前。
從本書的建議看來,聽起來好像utPLSQL在其框架中使用的標誌有錯誤。但它看起來像教程一樣......
當我創建測試包時,我通常使用類似於BEGIN UTPLSQL.RUN(owner_in =>'MY_USER',testpackage_in =>'MY_UNIT_TEST_PACKAGE')的代碼運行測試; END;'。請注意,我正在運行utPL/SQL的2.2版本,所以可能事情已經改變。 –
@BobJarvis我曾嘗試過,但它給出了語法錯誤,因爲我懷疑會發生。看起來,開發人員從v2完全重寫了v3,因此語法發生了巨大變化。 我不認爲問題是與運行()線,但與配置設置... – plasmaTonic
感謝您的這篇文章。我完全錯過了utplsql進行了升級。本週最佳新聞。我已經使用2.2了大約十年了。抱歉,我無法幫助您解決問題,但我今天晚上要下載新版本。 – APC