Insufficient privileges registering xml schema in database - oracle

using this instruction :
DBMS_XMLSCHEMA.REGISTERSCHEMA(filenamer,clobFile);
I have the following errors
ORA-31084: error while creating table "USER"."Document1592_TAB" for element "Document"
ORA-01031: insufficient privileges
ORA-06512: at "XDB.DBMS_XMLSCHEMA_INT", line 72
ORA-06512: at "XDB.DBMS_XMLSCHEMA", line 33
Of course this user can create tables, do you know where it could come from ?
thank you

Probably you don't have privileges to create,alter,drop,... types.
Also you can try to register xsd without creating any objects
DBMS_XMLSCHEMA.REGISTERSCHEMA(
schemaurl => filenamer
schemadoc => clobFile
gentypes => FALSE
gentables => FALSE
);

Related

Oracle APEX_WEB_SERVICE MAKE_REST REQUEST raise ORA-29273 and ORA-24247

I'm working on Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production and I need to develop a store procedure that access an API, I have to retrive the endpoint
https://api.my.host:8443/rest/ec/617643
I have set the oracle Wallet and added the certificate like this:
orapki wallet create -wallet /home/oracle/walletapi -pwd walletapi2022 -auto_login
orapki wallet add -wallet /home/oracle/walletapi -trusted_cert -cert /tmp/api.my.host.cer -pwd walletapi2022
I have set the ACE
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.my.host'
,lower_port => 8443
,upper_port => 8443
,ace => XS$ACE_TYPE(
privilege_list => XS$NAME_LIST('http')
,principal_name => 'MYUSER'
,principal_type => XS_ACL.ptype_db
)
);
DBMS_NETWORK_ACL_ADMIN.APPEND_WALLET_ACE (
wallet_path => 'file:/home/oracle/walletapi'
,ace => XS$ACE_TYPE(
privilege_list => XS$NAME_LIST('use_client_certificates', 'use_passwords')
,principal_name => 'MYUSER'
,principal_type => XS_ACL.ptype_db
));
Documentarion
In my store proc try this
...
l_clob := APEX_WEB_SERVICE.make_rest_request(
p_url => 'https://api.my.host:8443/rest/ec/617643'
,p_http_method => 'GET'
,p_wallet_path => 'file:/home/oracle/walletapi'
,p_wallet_pwd => 'walletapi2022'
);
...
Documentation
and this error is raised
ORA-29273: HTTP request failed
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 1182
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 782
ORA-24247: network access denied by access control list (ACL)
ORA-06512: at "SYS.UTL_HTTP", line 380
ORA-06512: at "SYS.UTL_HTTP", line 1127
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 756
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 1023
ORA-06512: at "APEX_210200.WWV_FLOW_WEB_SERVICES", line 1371
ORA-06512: at "APEX_210200.WWV_FLOW_WEBSERVICES_API", line 626
ORA-06512: at line 6
Applying the solution with CREATE_ACL and ASSIGN_ACL changes only the value of the ACL column in DBA_NETWORK_ACLS and DBA_NETWORK_ACL_PRIVILEGES views. So I removed ACLs and PRIVs and restart.
Reviewing this question, I noticed that this error is for "APEX_210222" which is one of the schemas created during Apex installation.
I tried
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.my.host'
,lower_port => 8443
,upper_port => 8443
,ace => XS$ACE_TYPE(
privilege_list => XS$NAME_LIST('http')
,principal_name => 'APEX_210222'
,principal_type => XS_ACL.ptype_db
)
and the web_service_request is now working correctly.

Oracle 11g data pump import job trying to create .DB files on the wrong drive

I know absolutely nothing about Oracle until attempting this restore. I have a .DMP file that I must restore. After many failed attempts I have issued the command:
alter system set DB_CREATE_FILE_DEST='E:\app\****\oradata\orcl';
because the data pump job keeps trying to put files on a D:\ that I cannot write to (it's a DVD drive). This DMP was created in Oracle 11g so that is what I've installed.
The error I get (many, many times) is like so:
O/S-Error: (OS 3) The system cannot find the path specified.
Failing sql is:
CREATE TABLESPACE "E:\APP\******\ORADATA\ORCL" DATAFILE 'D:\ORACLE\DATA\RRAEMR\LOGICIAN.DB' SIZE 251658240 AUTOEXTEND ON NEXT 5242880 MAXSIZE 2097152000,'D:\ORACLE\DATA\RRAEMR\LOGICIAN_DATA_0002.DB' SIZE 10
ORA-39083: Object type TABLESPACE failed to create with error:
ORA-01119: error in creating database file 'D:\ORACLE\DATA\RRAEMR\LOGIC_IX.DB'
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.
When I look at ALL_DIRECTORIES there is no directory pointed at D:\, all point to E:\ or C:\ or X:.
I should add that during the data pump import wizard I have tried remapping the tablespace files to where I want them and I do see some files landing there. I do not understand if this can be done for datafiles too. It looks like it should, but when adding a row and clicking it no datafile name is supplied like it was for tablespaces.
How can I restore this dump on a different drive?
EDIT:
Ok I am firing off another data pump import job without doing any remapping and within the first few seconds the log file already has errors like:
Failing sql is:
CREATE UNDO TABLESPACE "UNDOTBS" DATAFILE 'D:\ORACLE\DATA\RRAEMR\UNDOTBS01.DB' SIZE 20971520 AUTOEXTEND ON NEXT 5242880 MAXSIZE 2097152000,'D:\ORACLE\DATA\RRAEMR\UNDOTBS02.DB' SIZE 10485760 AUTOEXTEND ON NEX
ORA-39083: Object type TABLESPACE failed to create with error:
ORA-01119: error in creating database file 'D:\ORACLE\DATA\RRAEMR\TEMP_0003.DB'
ORA-27040: file create error, unable to create file
OSD-04002: unable to open file
O/S-Error: (OS 3) The system cannot find the path specified.
So it's still wanting to put on the D:. I captured the SQL for the job and here it is:
set scan off
set serveroutput on
set escape off
whenever sqlerror exit
DECLARE
s varchar2(1000);
h1 number;
errorvarchar varchar2(100):= 'ERROR';
tryGetStatus number := 0;
begin
h1 := dbms_datapump.open (operation => 'IMPORT', job_mode => 'FULL', job_name => 'IMP_SD_44-09_53_59', version => 'COMPATIBLE');
tryGetStatus := 1;
dbms_datapump.set_parallel(handle => h1, degree => 1);
dbms_datapump.add_file(handle => h1, filename => 'IMPORT-'||to_char(sysdate,'hh24_mi_ss')||'.LOG', directory => 'DMPDIR', filetype=>DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
dbms_datapump.set_parameter(handle => h1, name => 'KEEP_MASTER', value => 1);
dbms_datapump.add_file(handle => h1, filename => 'RRA.DMP', directory => 'DMPDIR', filetype => 1);
dbms_datapump.set_parameter(handle => h1, name => 'INCLUDE_METADATA', value => 1);
dbms_datapump.set_parameter(handle => h1, name => 'DATA_ACCESS_METHOD', value => 'AUTOMATIC');
dbms_datapump.set_parameter(handle => h1, name => 'REUSE_DATAFILES', value => 0);
dbms_datapump.set_parameter(handle => h1, name => 'TABLE_EXISTS_ACTION', value => 'REPLACE');
dbms_datapump.set_parameter(handle => h1, name => 'SKIP_UNUSABLE_INDEXES', value => 0);
dbms_datapump.start_job(handle => h1, skip_current => 0, abort_step => 0);
dbms_datapump.detach(handle => h1);
errorvarchar := 'NO_ERROR';
EXCEPTION
WHEN OTHERS THEN
BEGIN
IF ((errorvarchar = 'ERROR')AND(tryGetStatus=1)) THEN
DBMS_DATAPUMP.DETACH(h1);
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
RAISE;
END;
/

Oracle Datapump: Invalid operation at line 6224

I've a Oracle dump file that I'm trying to import to AWS RDS Oracle 12.1.0.2.v17
database.
The dump file looks like this:
$ strings EXPDP.dmp | head -n 6
_|lM
"PACOPROD"."SYS_EXPORT_SCHEMA_01"
IBMPC/WIN_NT64-9.1.0
unicode
AL32UTF8
12.01.00.00.00
The commands I'm running is:
DECLARE
hdnl NUMBER;
BEGIN
hdnl := DBMS_DATAPUMP.OPEN( operation => 'IMPORT', job_mode => 'SCHEMA', job_name=>null, version=>'COMPATIBLE');
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.dmp', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.ku$_file_type_dump_file);
DBMS_DATAPUMP.METADATA_FILTER(hdnl,'SCHEMA_EXPR','IN (''PACOPROD'')');
DBMS_DATAPUMP.START_JOB(hdnl);
END;
/
The response is:
Error report -
ORA-39002: invalid operation
ORA-06512: at "SYS.DBMS_DATAPUMP", line 6224
ORA-06512: at line 7
The closes similar issue I've found is this, even though it's not exactly the same error message and in my case both source and target db is running 12.1.
I think the issue is one of the following:
A) The DMP file is corrupt.
B) I'm doing something wrong.
I've no clue how to get further though. Where shall I dig or what should I try to go forward?
Try to add a log file to the operation. It some times contain more information:
DBMS_DATAPUMP.ADD_FILE( handle => hdnl, filename => 'EXPDP.log', directory => 'DATA_PUMP_DIR', filetype => dbms_datapump.KU$_FILE_TYPE_LOG_FILE);

How to register binary XML schema (using Oracle12c)?

I have a problem with registering BINARY XML schema using Oracle 12c version.
If I'm correct BINARY scheme registration option is available since Oracle 11g version? But using 12c it shows me an error that BINARY option is still not declared.
BEGIN
DBMS_XMLSCHEMA.REGISTERSCHEMA
(
SCHEMAURL => 'http://localhost:8080/public/leagues.xsd',
SCHEMADOC => bfilename('XMLDIR', 'LEAGUES.xsd'),
GENTYPES => FALSE,
OPTIONS => REGISTER_BINARYXML
);
END;
/
As a result of this, I receive an error :
PLS-00201: identifier 'REGISTER_BINARYXML' must be declared
Because that option (register_binaryxml) should be invoked through dbms_xmlschema package as dbms_xmlschema.register_binaryxml.
That is, replace options => register_binaryxml with options => dbms_xmlschema.register_binaryxml

Oracle PLSQL CreateSchemaBasedXML using multiple schemas

I am trying to perform XSD validation against an XML document within PLSQL and I'm having an issue with getting it working.
I have created an XMLTYPE object, which when I call isSchemaBased() against it returns 0 (false). Now obviously the XMLTYPE needs to be schema based in order to be validated, I found that you can make a schema based version by calling createSchemaBasedXML against the XMLTYPE. The problem I am having is that my schema is broken into two parts (combining the schema files is not an option unfortunately), which means that when I try and createSchemaBasedXML specifying the main schema it fails because it is unable to resolve a reference which is imported from the second XSD document.
-- lxml is the XMLTYPE which has been populated with the XML before this point
dbms_xmlschema.registerSchema(
schemaURL => mainSchemaURL,
schemaDoc => mainSchemaDoc,
local => true,
genTypes => true,
genTables => false,
force => true,
enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE);
dbms_xmlschema.registerSchema(
schemaURL => importedSchemaURL,
schemaDoc => importedSchemaDoc,
local => true,
genTypes => true,
genTables => false,
force => true,
enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_NONE);
if lxml.isSchemaBased() = 1 then
dbms_output.put_line('Schema based');
else
dbms_output.put_line('Non-schema based');
end if;
dbms_ouput.put_line('About to apply schema');
lxml := lxml.createSchemaBasedXML(mainSchemaURL);
dbms_ouput.put_line('We don't get this far');
lxml := lxml.createSchemaBasedXML(importedSchemaURL);
Is there any way of being able to import both the mainSchemaURL and the importedSchemaURL at the same time so that the imported schema references within the main schema don't cause the failure;
ORA-31079: unable to result reference to type [type containing imported type]
Any help or pointers would be greatly appreciated.
UPDATE: I am working with Oracle version 11g
The answer was provided by 'odie_63' on the Oracle forums [here][1]
In the end it was a case of specifying the schemaLocation for the import of the importedSchema
[1]: https://forums.oracle.com/message/11135111 "CreateSchemaBasedXML using multiple schemas
"

Resources