DBMS_RLS.add_policy: object_name not working - oracle

Hi guys, I'm learning the VPD feature of Oracle and I've got stuck at these below codes.
BEGIN
DBMS_RLS.add_policy(
object_schema => 'user_bacsi_01',
object_name => 'HOSOBENHNHAN',
policy_name => 'VPD_POLICY_DOCTOR_SEE_PATIENT_INFO',
policy_function => 'FUNC_VPD_POLICY_DOCTOR_SEE_PATIENT_INFO'
);
END;
/
Error
Error report -
ORA-00942: table or view does not exist
ORA-06512: at "SYS.DBMS_RLS_INT", line 23
ORA-06512: at "SYS.DBMS_RLS", line 54
ORA-06512: at line 2
00942. 00000 - "table or view does not exist"
*Cause:
*Action:
I've already created the table name 'HOSOBENHNHAN'. I don't understand the problem. Please help me!
Thank you!

Related

How to create a Redact Policy in oracle

I am trying to create a redact policy to hide NIC from Customer table for all users.
BEGIN
DBMS_REDACT.ADD_POLICY (
object_schema => 'RETAILX',
object_name => 'CUSTOMER',
column_name => 'NIC',
policy_name => 'REDACT_NIC_POLICY',
function_type => DBMS_REDACT.PARTIAL,
function_parameters => 'MDy1',
expression => '1=1'
);
END;
Above is my code for the policy creation. However, I am getting an error while creating the policy. Error as below.
ORA-06550: line 7, column 27:
PLS-00201: identifier 'DBMS_REDACT' must be declared
ORA-06550: line 2, column 2:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
What Could be wrong here?

ORA-31011: XML parsing failed on function condition

On a client's database (which I do not have physical access to) we are getting some strange results when joining to a function.
I was able to guide them to replicate the issue on a completely new schema within the same database.
create or replace function GEN_FILENAME(p_file_name varchar2) return varchar2
is
l_filename varchar2(100);
begin
l_filename := 'Test' || '/' || 'Test' || '.' || initcap(p_file_name) || '.txt';
return l_filename;
end GEN_FILENAME;
/
The function generates the following error if I use equals on a join, but is fine when I use a sub select for the function.
ORA-00604: error occurred at recursive SQL level 1
ORA-31011: XML parsing failed
ORA-19213: error occurred in XML processing at lines 1
LPX-00007: unexpected end-of-file encountered
00604. 00000 - "error occurred at recursive SQL level %s"
*Cause: An error occurred while processing a recursive SQL statement
(a statement applying to internal dictionary tables).
*Action: If the situation described in the next error on the stack
-- this query does not work
select dt.file_name,
GEN_FILENAME(dt.file_name) as file_name,
mf.file_path
from ( select 'Test' FOLDER,
'Test' AREA,
'File_Name' FILE_NAME,
systimestamp LAST_MODIFIED
from dual
) dt
left outer join (select 'Test/Test.File_Name.txt' file_path from dual) mf on mf.file_path = GEN_FILENAME(dt.file_name);
-- this query is working
select dt.file_name,
GEN_FILENAME(dt.file_name) as file_name,
mf.file_path
from ( select 'Test' FOLDER,
'Test' AREA,
'File_Name' FILE_NAME,
systimestamp LAST_MODIFIED
from dual
) dt
left outer join (select 'Test/Test.File_Name.txt' file_path from dual) mf on mf.file_path = (select GEN_FILENAME(dt.file_name) from dual);
I have seen other odd issues as well. I have asked them to gather statistics of the tables in the schema.
begin
for i in (select TABLE_NAME from USER_TABLES) loop
--Gather Table Statistics
sys.dbms_stats.gather_table_stats ( ownname => 'TEST', tabname => i.TABLE_NAME, cascade => true);
end loop;
end;
/
This resulted in the following error:
ORA-20000: Unable to analyze TABLE "TEST"."LOGMNR_SESSION_EVOLVE$", insufficient privileges or does not exist
ORA-06512: at "SYS.DBMS_STATS", line 40751
ORA-06512: at "SYS.DBMS_STATS", line 40024
ORA-06512: at "SYS.DBMS_STATS", line 40183
ORA-06512: at "SYS.DBMS_STATS", line 40732
ORA-06512: at line 5
ORA-06512: at line 5
I think this is all related, but I have never seen this type of issues before.
Any ideas?

Data Pump import fails with "job does not exist"

Can anyone help with this problem? I'm trying to use datapump to load a dump file created but whenever I try, I get the following code:
DECLARE
hdnl NUMBER;
status VARCHAR2(20);
BEGIN
hdnl := dbms_datapump.open (operation => 'IMPORT', job_mode => 'TABLE', version => 'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'import.log', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_log_file);
DBMS_DATAPUMP.ADD_FILE(handle => hdnl, filename => 'latest.dmp', directory => 'DP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.START_JOB(handle => hdnl);
DBMS_DATAPUMP.WAIT_FOR_JOB(hdnl,status);
end;
/
I'm getting this error:
Error report -
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 1852
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6793
ORA-06512: at line 5
31626. 00000 - "job does not exist"
*Cause: An invalid reference to a job which is no longer executing,
is not executing on the instance where the operation was
attempted, or that does not have a valid Master Table.
Refer to any following error messages for clarification.
*Action: Start a new job, or attach to an existing job that has a
valid Master Table.
Any idea?
Regards

DBMS_AQADM.PURGE_QUEUE_TABLE with the error ORA-01001: invalid cursor and ORA-06512: at "SYS.DBMS_AQ_INV"

While attempting to manually execute the command below with user APPS (owner of WF_BPEL_QTAB queue) the error informed is occurring.
We did all the necessary research and the queue has no indexes (as some solutions suggest).
Command:
declare
l_purge_options dbms_aqadm.aq$_purge_options_t;
begin
l_purge_options.Block := False;
DBMS_AQADM.PURGE_QUEUE_TABLE(queue_table => 'APPS.WF_BPEL_QTAB'
,purge_condition => 'ENQ_TIME < trunc(sysdate) - 3
,purge_options => l_purge_options);
end;
Error:
ORA-00604: error occurred at recursive SQL level 1
ORA-01001: invalid cursor
ORA-06512: at "SYS.DBMS_AQ_INV", line 208
ORA-00918: column ambiguously defined
ORA-06512: at "SYS.DBMS_AQADM", line 1668
ORA-06512: at line 5
When using criteria from the queue table, you need to use the alias 'qtview'. Hence
declare
l_purge_options dbms_aqadm.aq$_purge_options_t;
begin
l_purge_options.Block := False;
DBMS_AQADM.PURGE_QUEUE_TABLE(queue_table => 'APPS.WF_BPEL_QTAB'
,purge_condition => 'qtview.ENQ_TIME < trunc(sysdate) - 3
,purge_options => l_purge_options);
end;

ORA-31600 when using scan_percent with dbms_comparison.compare

I'm using Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production and I've created a comparison using this code :
BEGIN
DBMS_COMPARISON.CREATE_COMPARISON(
comparison_name => 'test2',
schema_name => 'someSchema',
object_name => 'someTable',
dblink_name => 'MYORACLEDB',
scan_mode => 'RANDOM',
scan_percent => 50);
END;
WHen i execute the comparison using
DECLARE
consistent BOOLEAN;
scan_info DBMS_COMPARISON.COMPARISON_TYPE;
BEGIN
consistent := DBMS_COMPARISON.COMPARE(
comparison_name => 'test2',
scan_info => scan_info,
perform_row_dif => FALSE);
END;
I get the following error message :
ORA-31600: invalid input value 1 for parameter data type in function a_plus_b_mul_c_minus_d
ORA-06512: at "SYS.DBMS_COMPARISON", line 547
ORA-06512: at line 7
31600. 00000 - "invalid input value %s for parameter %s in function %s"
*Cause: A NULL or invalid value was supplied for the parameter.
*Action: Correct the input value and try the call again.
When i run a comparison with the full scan mode i've got no error.
Anybody encountered such issue ?

Resources