ORA-22288: file or LOB operation FILEOPEN failed - sql

I have xml file abc.xml in \\192.168.1.71\err_log
I did below steps and getting error:
create directory XMLDIR2 as '\\192.168.1.71\err_log';
GRANT ALL ON DIRECTORY xmldir2 TO PUBLIC;
INSERT INTO example2
VALUES ( xmltype (
bfilename('XMLDIR2', 'abc.xml'),
nls_charset_id('AL32UTF8')
)
);
Getting below error:
ERROR at line 4: ORA-22288: file or LOB operation FILEOPEN failed
ORA-06512: at "SYS.XMLTYPE", line 296 ORA-06512: at line 1

Related

How do I get the size of a file(BFILE) in oracle g11 directly from a directory in my pc?

I was trying to get the size of a file from my desktop in Oracle SQL Developer, I'm working with a "BFILE" field.
And this is the query that I'm using
SET SERVEROUTPUT ON
DECLARE
v_bfile BFILE;
begin
select valor into v_bfile from TABLA_BFILE where id = 4;
DBMS_OUTPUT.PUT_LINE('El archivo ocupa: '||DBMS_LOB.GETLENGTH(v_bfile)||' bytes.');
end;
And I'm getting the next error
ORA-06512: en "SYS.DBMS_LOB", línea 787
ORA-06512: en línea 5
22285. 00000 - "non-existent directory or file for %s operation"
What I'm missing here?
Your code works fine.
The issue was with the population of the table.
The directory should not be a path but a DIRECTORY object.
create directory DESKTOP as 'C:\Users\Roberto\Desktop';
Insert into TABLA_BFILE (ID,valor) values (1,BFILENAME('DESKTOP','oracle.jpg'));

`FOR UPDATE` breaks batch execution in HANA

HANA 102.05 fails to execute the following code:
CREATE TABLE ATABLE( f INT );
CREATE PROCEDURE TestProc()
AS
BEGIN
SELECT f FROM ATABLE
FOR UPDATE; -- Without FOR UPDATE it works
END;
SELECT 'Hello' FROM DUMMY;
complaining that:
SAP DBTech JDBC: [257]: sql syntax error: incorrect syntax near "SELECT": line 8 col 2 (at pos 124)
which points outside the proceudure, at SELECT 'Hello'. The procedure itself compiles without error. The entire script completes successfully if I remove the FOR UPDATE directive. What is wrong with the original?
Update
When I execute the same query from hdbsql.exe I get:
0 rows affected (overall time 26,076 msec; server time 6518 usec)
* 257: sql syntax error: line 5 col 9 (at pos 71) SQLSTATE: HY000
* 257: sql syntax error: incorrect syntax near "END": line 2 col 1 (at pos 32) SQLSTATE: HY000
'Hello'
"Hello"
1 row selected (overall time 4644 usec; server time 143 usec)

sqlite3 fails to import db from sql file

I'm trying to install PolicyD v2, but when creating sqlite3 database from sql file it throw errors:
SQLite version 3.7.17 2013-05-20 00:56:22
sqlite> .read /usr/doc/policyd2-2.0.14/policyd2.sqlite
Error: near line 1: unrecognized token: "#"
Error: near line 43: no such table: policies
Error: near line 44: no such table: policies
Error: near line 45: no such table: policies
Error: near line 46: no such table: policies
Error: near line 47: no such table: policies
Error: near line 174: unrecognized token: "#"
Error: near line 215: unrecognized token: "#"
Error: near line 263: no such table: quotas
Error: near line 264: no such table: quotas
Error: near line 303: unrecognized token: "#"
Error: near line 447: no such table: amavis_rules
Error: near line 462: unrecognized token: "#"
Error: near line 570: unrecognized token: "#"
Error: near line 617: unrecognized token: "#"
And /usr/doc/policyd2-2.0.14/policyd2.sqlite looks like this:
line:1 # Core schema
line:2 # Copyright (C) 2009, AllWorldIT
line:3 # Copyright (C) 2008, LinuxRulz
...
/* Policies */
CREATE TABLE policies (
ID INTEGER PRIMARY KEY AUTOINCREMENT,
Name VARCHAR(255) NOT NULL,
Priority SMALLINT NOT NULL,
Description TEXT,
Disabled SMALLINT NOT NULL DEFAULT '0'
) ;
...
line:43 INSERT INTO policies (Name,Priority,Description) VALUES ('Default',0,'Default System Policy');
line:44 INSERT INTO policies (Name,Priority,Description) VALUES ('Default Outbound',10,'Default Outbound System Policy');
line:45 INSERT INTO policies (Name,Priority,Description) VALUES ('Default Inbound',10,'Default Inbound System Policy');
line:46 INSERT INTO policies (Name,Priority,Description) VALUES ('Default Internal',20,'Default Internal System Policy');
line:47 INSERT INTO policies (Name,Priority,Description) VALUES ('Test',50,'Test policy');
Created tables:
sqlite> .tables
checkhelo_blacklist policy_group_members
checkhelo_tracking policy_groups
checkhelo_whitelist policy_members
greylisting_autoblacklist quotas_limits
greylisting_autowhitelist quotas_tracking
greylisting_tracking session_tracking
greylisting_whitelist
I can create 'policies', 'quotas', 'amavis_rules' tables by hand.
So whats wrong here? Other tables were created.
It is caused by console and some malformed (encoding/decoding) characters in file like tab,space,new line.
Solution for this is using grep.
grep -v "#" sql.file | sqlite3 sqlite3.db

Cannot export the ORDDataSource object with an external source

I'm trying create a procedure like this:
CREATE OR REPLACE PROCEDURE export_dicom (identyfikator_wyniku number, new_file_name varchar2)
AS
obr ORDDicom;
BEGIN
SELECT dicom_zrodlo INTO obr FROM wyniki WHERE id_wyniku = identyfikator_wyniku;
obr.export('FILE', 'MEDIA_FILES', new_file_name);
END;
But when I create it and use it, I get an error like this:
ORA-53216: cannot export the ORDDataSource object with an external source
ORA-06512: at "ORDSYS.ORDERROR", line 5
ORA-06512: at "ORDSYS.ORDDATASOURCE", line 265
ORA-06512: at "ORDSYS.ORDDICOM", line 234
ORA-06512: at "ZAD2.export_dicom", line 6
ORA-06512: at line 1
Anyone know how to fix it?

ORA-22275 error: invalid LOB locator specified

I have a procedure that populates a BLOB variable with a PDF document. What I am trying to do is add logic to only display the PDF document within a 60 day period from a static date. See below:
check_staticdate number(1);
function DisplayPDF (audit in number) RETURN blob is
person_id person.person_id%type;
z_lob blob;
blob_length NUMBER;
CURSOR getPDF(audit number) IS
select report
from report_table
where report_type = 'PDF'
and job_no = audit order by rec_no;
begin
/* Check Valid ID */
if not package.ValidID(person_id, check_only=>TRUE) then
return z_lob;
end if;
/* Here is the case statement.*/
select case
when exists
(
SELECT 'x' from table
where table_id = person_id
and trunc(sysdate) < trunc(table_static_date + 60)
)
then 1
else 0
end into check_staticdate
from dual;
if (check_staticdate = 0) then
return z_lob;
end if;
open getPDF(audit);
fetch getPDF into z_lob;
close getPDF;
return z_lob;
end DisplayPDF;
The error I am receiving is: ORA-22275: invalid LOB locator specified.
I am new to Oracle SQL, and am unsure why my ValidID check works by returning z_lob but my case statement does not.
Edit: Adding full error stack
Failed to execute target procedure ORA-22275: invalid LOB locator specified
ORA-06512: at "SYS.WPG_DOCLOAD", line 51
ORA-06512: at "User.Package", line 733
ORA-06512: at line 33
Initialise your lob with temporary first
DBMS_LOB.CREATETEMPORARY(z_lob,true); --true if you want it to be cached.
Your function is probably returning (depending on your audit parameter value) a blob with a NULL value to the SYS.WPG_DOCLOAD method which throws the unhandled exception you see.
Perhaps you could modify your return z_lob; to be return nvl(z_lob, empty_blob());