UTL_FILE is reportable
Helllo,I am running Application Express on my PC. I have loaded OracleXE, and then updated on-demand Express 3.0.3.00.08. I am running Oracle Database 10g Express. When I speak of 'UTL_FILE' package, I get a "'UTL_FILE' must be declared ORA-06550:"error. " Anyone have any suggestions on how to solve this problem. Thanks in advance.
Sharon
PC request Info Express.
Construction product: 3.0.1.00.08 database Version information
Compatibility of the schema: 2007.05.25 Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
Last hour DDL: 2008-09-24 13:45:58 PL/SQL Release 10.2.0.1.0 - Production
I guess that, in the 10th, the UTL_FILE package is not granted EXECUTE to the PUBLIC.
You must log in as a user of the SYSTEM, and run:
GRANT EXECUTE ON utl_file to
where
Twelve, you'll need to:
Bye,. -----------------------------------------
1 create a directory pointing to the folder object.
2 grant read and/or write privileges on the directory you want to access it as
Flavio
http://www.oraclequirks.com
Tags: Database
Similar Questions
-
Problem with the UTL_File
Hello friends,
I use UTL_FILE for reporting, but when I used the SQL query in the procedure, then it shows the 740 records
and when I run the query individually (query that is used in the cursor) then it shows 790 records that is correct.
Is that utl_file has some limitations of memory will only process more than 700 files.
CREATE OR REPLACE PROCEDURE extract_data
IS
v_handle UTL_FILE.file_type;
T_DATE VARCHAR2 (20);
VMO VARCHAR2 (10);
v_bookdate DATE;
vyr VARCHAR2 (10);
BEGIN
v_handle: = UTL_FILE.fopen ("/ home/sanjays/UPDATED / ', 'test.xls', 'W');
SELECT TO_CHAR (SYSDATE, 'Mon - rr') INTO HOV
FROM DUAL;
T_DATE: = '01-' | VMO;
SELECT dat_process
IN v_bookdate
OF ba_bank_mast@fl02rrpt;
UTL_FILE.PUTF (v_handle,
"Data file is on reservation Date % s\n\n"
To_date (v_bookdate, 'DD-Mon-YYYY')
);
FOR rec IN (SELECT cod_cc_brn AS brn_code, COUNT (cod_acct_no): lan,)
SUM (amt_disbursed) AS amt_disbursed
OF ln_acct_mast@fl02rrpt
WHERE cod_acct_stat = 8 AND dat_first_disb > = '' 01-Sep-08
-to_date(V_DATE,'dd-mon-yyyy')
GROUP BY cod_cc_brn)
LOOP
UTL_FILE.put_line (v_handle,
Rec.brn_code
|| ' '
|| Rec.LAN
|| ' '
|| Rec.amt_disbursed
);
END LOOP;
END extract_data;
/
Kindly help me with this problem.
Its urgency.
Kind regards
AnandDid you close the file once you get out of the loop, otherwise the pads cannot be emptied and some records cannot be written.
-
How to report on Oracle 11 g XE UTL_FILE.
Hi, I have installed Oracle 11 g XE and the need to declare UTL_FILE.
When you run a package you get the error: PLS-00201: identifier 'UTL_FILE' must be declared.
In different forums to refer both to create a SYS user and I use the command:
Grant execute on UTL_FILE sys;
The problem is that there is no SYS user in Oracle 11 g XE. There is only the SYSTEM user.
When I connect as a system and apply order GRANT... and I get the error:
ORA-00942: table or view does not exist
How I UTL_FILE grant and report to Oracle 11 g XE?
I'm sorry, my English isn't the best.
Hello
Of course UTL_FILE exists in Oracle 11 g XE. To grant access, you will need to connect as user SYS.
Try "sqlplus / as sysdba" to the console of the server to connect as sys. Make sure you are in a group ORA_DBA OS (Windows) or the Group dba (Linux)
Best regards!
-
Filing of report generation error
Hello
I get the following error message when you try to generate a report of my filing of statement:
In the log file, I see these lines:
2016-02-13 10:17:12, 995 [Thread-287] ReportsGenerationDialog - exception Reporting scheme report generation - ERROR ORA-29282: ID of person invalido
ORA-06512: em 'SYS. UTL_FILE", line 878
ORA-06512: em 'REST. PKG_OSDM_UTILS', line 5634
ORA-01403: dados nao found
ORA-06512: em line1
This happens to be it, if I put a directory object or a normal directory in the directory path.
I'm doing something wrong?
Here is a screenshot of the dialog reports:
Thank you
Wolf
Hi Wolf,
I have re-attached package PLSQL.
Re-compile the body again and you shouldn't get NPE more.
As it comes to workaround, the downside is that not all PDF diagrams will be generated. In the first place, there is a problem with them, and it will be fixed in the next version.
The yard will be also addressed.
Concerning
-
I have tried the code
DECLARE
lv_url VARCHAR2 (1000): = ' http://shenzhoufellowship.org/main2/files/old/SpecialTopics/TheLoveDare.pdf';
lc_return BLOB;
lhttp_url httpuritype.
Varriables - declared to have written the LOB to pdf file-
l_file UTL_FILE. TYPE_DE_FICHIER;
l_buffer RAW (32767).
l_amount directory: = 32767;
l_pos INTEGER: = 1;
l_blob BLOB;
l_blob_len INTEGER.
BEGIN
-create URIs
lhttp_url: = httpuritype.createuri (lv_url);
-get the PDF document
lc_return: = lhttp_url.getblob ();
-Open the destination file.
l_file: = UTL_FILE. FOPEN ('MBO_INPUT_DIR', 'MBD.zip', 'wb');
-Get the total length of the BLOB
l_blob_len: = DBMS_LOB.getlength (lc_return);
-Pieces of the BLOB to read and write to the file
-full up.
While l_pos < l_blob_len LOOP
DBMS_LOB. READ (lc_return, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw (l_file, l_buffer, FALSE);
l_pos: = l_pos + l_amount;
END LOOP;
-Closes the file.
UTL_FILE. FCLOSE (l_file);
EXCEPTION
WHILE OTHERS THEN
-Close the file if something goes wrong.
IF UTL_FILE.IS_OPEN (l_file) THEN
UTL_FILE. FCLOSE (l_file);
END IF;
LIFT;
END;
But make a mistake like:
Error report-
ORA-29273: HTTP request failed
ORA-06512: at "SYS." UTL_HTTP", line 1130
ORA-12535: TNS:operation expired
ORA-06512: at line 37 level
29273 00000 - "the HTTP request failed.
* Cause: The UTL_HTTP package cannot run the HTTP request.
* Action: Use get_detailed_sqlerrm to check the detailed error message.
Correct the error and restart the HTTP request.
Please suggest a solution. Is it possible to download a zip file with the same code?
[oracle@localhost ~]$ sqlplus scott/tiger SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 6 13:59:09 2015 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> --My Database version SQL> ---------------------- SQL> SELECT * FROM v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production SQL> ed Wrote file afiedt.buf 1 DECLARE 2 lv_url VARCHAR2(500) := 'http://shenzhoufellowship.org/main2/files/old/SpecialTopics/TheLoveDare.pdf'; 3 lc_return BLOB; 4 lhttp_url httpuritype; 5 ---Varriables declared for writing the LOB to pdf file -- 6 l_file UTL_FILE.FILE_TYPE; 7 l_buffer RAW(32767); 8 l_amount BINARY_INTEGER := 32767; 9 l_pos INTEGER := 1; 10 l_blob BLOB; 11 l_blob_len INTEGER; 12 BEGIN 13 --create uri 14 lhttp_url := httpuritype.createuri(lv_url); 15 --get the PDF document 16 lc_return := lhttp_url.getblob(); 17 -- Open the destination file. 18 l_file := UTL_FILE.FOPEN('SAUBHIK', 'TheLoveDare.pdf', 'wb'); 19 --Get the total length of the BLOB 20 l_blob_len := DBMS_LOB.getlength(lc_return); 21 -- Read chunks of the BLOB and write them to the file 22 -- until complete. 23 WHILE l_pos < l_blob_len LOOP 24 DBMS_LOB.READ(lc_return, l_amount, l_pos, l_buffer); 25 UTL_FILE.put_raw(l_file, l_buffer, FALSE); 26 l_pos := l_pos + l_amount; 27 END LOOP; 28 -- Close the file. 29 UTL_FILE.FCLOSE(l_file); 30 EXCEPTION 31 WHEN OTHERS THEN 32 -- Close the file if something goes wrong. 33 IF UTL_FILE.IS_OPEN(l_file) THEN 34 UTL_FILE.FCLOSE(l_file); 35 END IF; 36 RAISE; 37* END; 38 / DECLARE * ERROR at line 1: ORA-29273: HTTP request failed ORA-06512: at "SYS.UTL_HTTP", line 1130 ORA-24247: network access denied by access control list (ACL) ORA-06512: at line 36 SQL> conn sys as sysdba Enter password: Connected. SQL> ed Wrote file afiedt.buf 1 BEGIN 2 DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(acl => 'love.xml', 3 description => 'Love ACL', 4 principal => 'SCOTT', 5 is_grant => true, 6 privilege => 'connect'); 7 DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(acl => 'love.xml', 8 principal => 'SCOTT', 9 is_grant => true, 10 privilege => 'resolve'); 11 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(acl => 'love.xml', 12 host => 'shenzhoufellowship.org'); 13 commit; 14* END; 15 / PL/SQL procedure successfully completed. SQL> conn scott/tiger Connected. SQL> ed Wrote file afiedt.buf 1 DECLARE 2 lv_url VARCHAR2(500) := 'http://shenzhoufellowship.org/main2/files/old/SpecialTopics/TheLoveDare.pdf'; 3 lc_return BLOB; 4 lhttp_url httpuritype; 5 ---Varriables declared for writing the LOB to pdf file -- 6 l_file UTL_FILE.FILE_TYPE; 7 l_buffer RAW(32767); 8 l_amount BINARY_INTEGER := 32767; 9 l_pos INTEGER := 1; 10 l_blob BLOB; 11 l_blob_len INTEGER; 12 BEGIN 13 --create uri 14 lhttp_url := httpuritype.createuri(lv_url); 15 --get the PDF document 16 lc_return := lhttp_url.getblob(); 17 -- Open the destination file. 18 l_file := UTL_FILE.FOPEN('SAUBHIK', 'TheLoveDare.pdf', 'wb'); 19 --Get the total length of the BLOB 20 l_blob_len := DBMS_LOB.getlength(lc_return); 21 -- Read chunks of the BLOB and write them to the file 22 -- until complete. 23 WHILE l_pos < l_blob_len LOOP 24 DBMS_LOB.READ(lc_return, l_amount, l_pos, l_buffer); 25 UTL_FILE.put_raw(l_file, l_buffer, FALSE); 26 l_pos := l_pos + l_amount; 27 END LOOP; 28 -- Close the file. 29 UTL_FILE.FCLOSE(l_file); 30 EXCEPTION 31 WHEN OTHERS THEN 32 -- Close the file if something goes wrong. 33 IF UTL_FILE.IS_OPEN(l_file) THEN 34 UTL_FILE.FCLOSE(l_file); 35 END IF; 36 RAISE; 37* END; 38 / PL/SQL procedure successfully completed. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@localhost ~]$ cd saubhik/ [oracle@localhost saubhik]$ pwd /home/oracle/saubhik [oracle@localhost saubhik]$ ls -l *.pdf -rw-r--r-- 1 oracle oinstall 60055 Apr 6 14:03 TheLoveDare.pdf [oracle@localhost saubhik]$
I love this pdf file. I would like to read this and mean while if you get an error then please post in its entirety and also think that it is an Oracle error or network.
-
Getting ORA-29280: directory path invalid as he tried to call utl_file
I've seen a lot of posts on this, but none of the suggestions work. I tried many variations of the following and I pretty much get the same error on different lines. See below for the error.
My code is as follows:
CREATE or REPLACE DIRECTORY LOAD_SRC as 'C:\Stuff\BulkInsert ';
-Select * from all_directories where directory_name = "LOAD_SRC"; C:\Stuff\BulkInsert is in the list
DECLARE
sale_amount NUMBER;
LOAD_SRC VARCHAR2 (50); -If I do not add it I get the following msg: PLS-00201: identifier 'LOAD_SRC' must be declared
FILE_HANDLE utl_file.file_type;
BEGIN
FILE_HANDLE: = utl_file.fopen (LOAD_SRC, 'stuff.dat', 'W', 256);--29280. 00000 - "invalid directory path.
Sum (sale_amount) SELECT INTO sale_amount OF POS_RECORD; - where sale_amount like '% ';
UTL_FILE.put_line (FILE_HANDLE, sale_amount);
UTL_FILE.fclose (FILE_HANDLE);
END;
/
@@@@@@@@@@@@@@@@@@@@@@@
Error:
CREATE or REPLACE DIRECTORY succeeded.
Error from line 3 in order:
DECLARE
sale_amount NUMBER;
LOAD_SRC VARCHAR2 (50); -If I do not add it I get the following msg: PLS-00201: identifier 'LOAD_SRC' must be declared
FILE_HANDLE utl_file.file_type;
BEGIN
FILE_HANDLE: = utl_file.fopen (LOAD_SRC, 'stuff.dat', 'W', 256);--29280. 00000 - "invalid directory path.
Sum (sale_amount) SELECT INTO sale_amount OF POS_RECORD; - where sale_amount like '% ';
UTL_FILE.put_line (FILE_HANDLE, sale_amount);
UTL_FILE.fclose (FILE_HANDLE);
END;
Error report:
ORA-29280: invalid directory path
ORA-06512: at "SYS." UTL_FILE", line 41
ORA-06512: at "SYS." UTL_FILE", line 478
ORA-06512: at line 6
29280 00000 - "invalid directory path.
* Cause: A corresponding directory object does not exist.
* Action: Correct the parameter object directory, or create a correspondent
object directory with the command CREATE a DIRECTORY.
Is C:\Stuff\BulkInsert on your Oracle database server?
In addition, FILE_HANDLE: = utl_file.fopen(LOAD_SRC,'stuff.dat','W',256); ==> FILE_HANDLE: is utl_file.fopen('LOAD_SRC','stuff.dat','W',256);. If you declare a varriable put this string into that and then refer to your code.
-
UTL_FILE writing question
Hello
Impossible to write something in a file.
DIRETCOTY NAME: UPLOAD_FILE
FILE NAME: call_details_report.txt
Here's the code,
Help, please.
-CREATE OR REPLACE PROCEDURE CALL_RCDR_RPT (V_DT IN TAB_CALL_RCDR_REPORT_DAILY. DT % TYPE)
CREATE OR REPLACE PROCEDURE CALL_RCDR_RPT
ISRPT of the cursor IS
SELECT DT, DESCR_ID, DESCR, UNQ_USR, SOFT, REV, CALL_CNT
OF TAB_CALL_RCDR_REPORT_DAILY;
-WHERE DT = V_DT;v_rpt_rcd rpt % rowtype;
v_stmt varchar2 (300);
v_head varchar2 (300);
v_line varchar2 (500);
-V1 VARCHAR2 (50);
-v1: = "CALL_DTLS_RPT"; -creation of name of filesv_file UTL_FILE. TYPE_DE_FICHIER;
BEGINv_file: = utl_file.fopen('UPLOAD_FILE','call_details_report.txt','W');
UTL_FILE.put_line (v_file,' report generated on :'|| sysdate);
UTL_FILE.new_line (v_file);
v_head: = ' DT, DESCR_ID, DESCR, UU, SOFT, REV, CALL_CNT;
UTL_FILE. PUTF (v_file, v_head);
UTL_FILE.new_line (v_file);
v_line:= '==================================================================================================';
UTL_FILE. PUTF (v_file, v_line);
for v_rpt_rcd in the loop of the rpt
v_stmt: = to_char (v_rpt_rcd. DT)
||','||
TO_CHAR (v_rpt_rcd. DESCR_ID)
||','||
TO_CHAR (v_rpt_rcd. DESCR)
||','||
TO_CHAR (v_rpt_rcd. UNQ_USR)
||','||
TO_CHAR (v_rpt_rcd. MOU)
||','||
TO_CHAR (v_rpt_rcd. REV)
||','||
TO_CHAR (v_rpt_rcd. CALL_CNT);
UTL_FILE. PUTF (v_file, v_stmt);
UTL_FILE.new_line (v_file);
end loop;
UTL_FILE.fclose (v_file);
exceptionwhile others then
dbms_output.put_line (SQLERRM);END CALL_RCDR_RPT;
Check if you have OS level write permision to user oracle to write to the directory of the OS.
Also simplyfy your code like this. Do not use EXCEPTION SO than OTHERS the way that you used. His incorrect answer. You don't need in the first place. Remove it.
create or replace procedure call_rcdr_rptis v_file utl_file.file_type; begin v_file := utl_file.fopen('UPLOAD_FILE','call_details_report.txt','w'); utl_file.put_line(v_file,'report generated on: '|| sysdate); utl_file.new_line(v_file); utl_file.put_line(v_file, 'dt,descr_id,descr,uu,mou,rev,call_cnt'); utl_file.put_line(v_file, rpad('=', 98, '=')); for v_rpt_rcd in ( select dt , descr_id , descr , unq_usr , mou , rev , call_cnt from tab_call_rcdr_report_daily ) loop utl_file.put_line ( v_file , to_char(v_rpt_rcd.dt) ||','|| to_char(v_rpt_rcd.descr_id) ||','|| to_char(v_rpt_rcd.descr) ||','|| to_char(v_rpt_rcd.unq_usr) ||','|| to_char(v_rpt_rcd.mou) ||','|| to_char(v_rpt_rcd.rev) ||','|| to_char(v_rpt_rcd.call_cnt) ); end loop; utl_file.fclose(v_file);end call_rcdr_rpt;
-
Ask about UTL_FILE stored procedure
Hello
I tried to do an insert into a table which then triggers a stored procedure to write the data inserted into a text file. However, I have a few questions here in the stored procedure. Thanks for trying to help... [Insert-> table-> Trigger-> stored procedure-> text file]
-The user will execute this sql
-insert into tester.test_table values ("ab");
CREATE TABLE TESTER. TEST_TABLE
(
LINECODE VARCHAR2 (2 BYTE)
)
-Just for test purpose
CREATE TABLE TESTER. TEST_REC_TABLE
(
LINECODE VARCHAR2 (2 BYTE)
)
CREATE OR REPLACE TRIGGER TESTER. TRIGGER_AUDIT
AFTER INSERT OR UPDATE
TESTER MARKET. TEST_TABLE REFERENCING OLD AS OLD AGAIN AS NEW
FOR EACH LINE
DECLARE
sLineCode VARCHAR2 (2);
BEGIN
sLineCode: = ";
IF THE UPDATE CAN
sLineCode: =: NEW. LINECODE;
TRIGGER_PACKAGE. WRITE_FILE (sLineCode);
END IF;
IF THE INSERTION
sLineCode: =: NEW. LineCode;
TRIGGER_PACKAGE. WRITE_FILE (sLineCode);
END IF;
EXCEPTION
WHEN other then null;
END TRIGGER_AUDIT;
/
CREATE OR REPLACE PACKAGE BODY TESTER. TRIGGER_PACKAGE
is
procedure WRITE_FILE (in_LineCode in varchar2)
is
sLineCode varchar2 (2);
v_FileHandle UTL_FILE. TYPE_DE_FICHIER;
-a few checks for null input data
Start
If ((rtrim (in_LineCode) IS NULL) or (in_LineCode is nothing)) then
sLineCode: = "XX";
on the other
sLineCode: = in_LineCode; -> PROBLEM HERE?
end if;
If (length (sLineCode) > 2) can
sLineCode: = substr (sLineCode, 1, 2);
end if;
Insert into TEST_REC_TABLE (LineCode) values (sLineCode); -Insert data to another table for the test
RUN IMMEDIATELY 'CREATE OR REPLACE DIRECTORY FILEDIR AS | '''' || 'c:\' || '''';
v_FileHandle: = UTL_FILE. FOPEN ('FILEDIR', 'Test_Table.txt', 'w'); -write in the text file in C:\Test_Table.txt
UTL_FILE. Put_line (v_FileHandle, 'insert' | sLineCode |) ' @ ' || TO_CHAR(SYSDATE,'DD-MM-YYYY HH:MI:SS AM'));
UTL_FILE. FCLOSE (v_FileHandle);
exception
When other then null;
end;
end TRIGGER_PACKAGE;
/
(1) the problem I encountered is that when I run sql INSERT for new data, it can be successfully be inserted in both tables TEST_REC_TABLE and table_test, but just do not write in the text file.
(2) However, when I simply run the procedure I'll get XX for data entry because it is NULL. These data XX then will be seen in TEST_REC_TABLE in the folder "XX" and Test_Table.txt as "Inserted XX @ 01/10/2014-16:56:06. UTL_FILE wrote to textfile so my guess is that it could be due to my misunderstanding of the logic in the audit input null data. Tried, but I'm still distraught, thanks for reporting the issue.
> 1) I'm just tests and I'm learning here with insert trigger...
Good. In this case, it's just a bad choice that you have decided to write to a file of a trigger. Basic Oracle is a good site. They also have examples. Please check that the BASE ORACLE - overview of database triggers.
(> 2) how do I do next?
Simply create the object once
CREATE OR REPLACE DIRECTORY FILEDIR AS
The path must be a location on your server where oracle is installed.
(> 3) how do I do next? Use this?
EXCEPTION
WHILE OTHERS THEN
DBMS_OUTPUT. PUT_LINE
("ERROR" |) TO_CHAR (SQLCODE) | SQLERRM);
NULL;
Do not do something. Just remove the exception handling. Do not handle unknown exceptions. If all you want to manage the purpose of logging RECOVERY to end like that.
exception
while others then
lift;
And on one of the exceptions management forum, member BluShadow has written a nice article 101 PL/SQL: exception management. It would be an enjoyable read.
-
Hi gurus
I use this Procedure to generate the csv file of linux DB server and save it to the windows file system.
Select * from dba_directories;
SYS CREDIT_REPORTS /cifs/mnt/credit_report I checked that Samba is running.
[root@abcoracle ~] # ps - ef | grep smbd
32295 root 32096 0 22:01 pts/2 00:00:00 grep smbd
My proc
create or replace
Run_query P_sql() PROCEDURE in VARCHAR2
,, p_dir IN VARCHAR2
,, p_header_file IN VARCHAR2
,, p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt(VARCHAR2) 4000);
v_v_val(VARCHAR2) 4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER.
f BOOLEAN;
rec_tab DBMS_SQL. DESC_TAB;
col_num NUMBER;
UTL_FILE. v_fh TYPE_DE_FICHIER;
BOOLEAN := v_samefile (NVL ()p_data_file p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL. OPEN_CURSOR;
DBMS_SQL. ANALYSIS() c, p_sql,. DBMS_SQL NATIVE);
d := DBMS_SQL. RUN() c);
DBMS_SQL. DESCRIBE_COLUMNS() c, col_cnt, rec_tab);
FOR j 1. . col_cnt
LOOP
CASE rec_tab() j). col_type
WHEN 1 THEN DBMS_SQL. DEFINE_COLUMN() c v_v_val j , 2000);
WHEN 2 THEN DBMS_SQL. DEFINE_COLUMN() c v_n_val j );
WHEN 12 THEN DBMS_SQL. DEFINE_COLUMN() c v_d_val j );
ON THE OTHER
DBMS_SQL. DEFINE_COLUMN() c v_v_val j , 2000);
END CASE;
END LOOP;
-This section displays the header
v_fh: = UTL_FILE. FOPEN (Upper (p_dir), p_header_file, 'w', 32767);
FOR j 1. . col_cnt
LOOP
v_finaltxt := ltrim()v_finaltxt | «, » || down() rec_tab() j). column-name), ',');
END LOOP;
-DBMS_OUTPUT. Put_line ()v_finaltxt);
UTL_FILE. Put_line ()v_fh, v_finaltxt);
IF this is v_samefile THEN
UTL_FILE. FCLOSE ()v_fh);
END IF;
--
-This part generates the DATA
IF this is v_samefile THEN
v_fh: = UTL_FILE. FOPEN (Upper (p_dir), p_data_file, 'w', 32767);
END IF;
LOOP
v_ret :=. DBMS_SQL C FETCH_ROWS();
WHEN OUTPUT v_ret = 0;
v_finaltxt := NULL;
FOR j 1. . col_cnt
LOOP
CASE rec_tab() j). col_type
WHEN 1 THEN DBMS_SQL. COLUMN_VALUE() c v_v_val j );
v_finaltxt := ltrim("v_finaltxt |', ' ' | v_v_val |'" ',','");
WHEN 2 THEN DBMS_SQL. COLUMN_VALUE() c v_n_val j );
v_finaltxt := ltrim()v_finaltxt | «, » || v_n_val, ",");
WHEN 12 THEN DBMS_SQL. COLUMN_VALUE() c v_d_val j );
v_finaltxt: = ltrim (v_finaltxt |) ',' || TO_CHAR (v_d_val, ' DD/MM/YYYY HH24:MI:SS'), ',');
ON THE OTHER
v_finaltxt := ltrim("v_finaltxt |', ' ' | v_v_val |'" ',','");
END CASE;
END LOOP;
-DBMS_OUTPUT. Put_line ()v_finaltxt);
UTL_FILE. Put_line ()v_fh, v_finaltxt);
END LOOP;
UTL_FILE. FCLOSE ()v_fh);
DBMS_SQL. C CLOSE_CURSOR();
END;
Proc call
Exec run_query() ' SELECT d. DEBTORNO AS 'DebtorNo', d. Name NAME AS, d. MOTORCARRNO AS "MC # ', trunc()d. CREDEXPIREDATE) AS 'Expiring Credit Date', d. CREDEXPIREMOS AS 'Credit expires in many months' OF DEBTORS d WHERE d. CREDEXPIREMOS (3, 6, 9, 12) AND TRUNC()d. CREDEXPIREDATE) > = SysDate TRUNC()-1 AND d. NOBUYDESC is null AND (d. ) NOBUYDISPUTEKEY has the value NULL OR d. (NOBUYDISPUTEKEY = 0) order by 2 ',' Credit_reports ',' credit_exp.csv')
Errors
Error at startup on line 2 of the command:
Error report:
ORA-29283: invalid file operation
ORA-06512: at «SYS. » UTL_FILE", line 536
ORA-29283: invalid file operation
ORA-06512: at "ABCBI. . RUN_QUERY', line 36
ORA-06512: at line 1
29283 00000 - "invalid file operation.
* Cause: An attempt was made to read from a file or a directory which is
not exist, or the file or directory access was denied by the
operating system.
* Action: Check access privileges to the file and directory on the file system
and if reading, check that the file exists.
Check first agree on this directory CREDIT_REPORTS
Grant read, write on CREDIT_REPORTS for
; Second, try to create any file in ' / mnt/cifs/credit_report "by oracle at the level of the OS user and verify that you have access to do this.
----
Ramin Hashimzade
-
Image coding in XML report definition
A number of reports, I have the report in XML format definition. These files contain embedded images.
How can I retrieve the xml image files. It looks like not the strings for images are not base16 or base64-coded?Work with something like that?
]]> FF8DFF0E 0001A464 94640010 10100006 00060000 FFBD0048 0001B0C0 E0C0A001 E0D0E021 11013181 82A18161 61811332 52D182A3 33D3C393 33837304 84C5E404 44755473 8305D615 75F52676 8676E3D4 17970746 87C55676 36101121 21815181 F2A1A1F2 36248324 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 36363636 3636FF4C 102A0000 [...] D29681A8 4EB94557 F3D8D588 912F1FCE A2478278 4E157FE8 D3B2F257 A1906D14 A809D102 9F646EFF 007CA66A B08C98EF 2E5344BB 4978EEAD 55093F75 6A4E8D29 345ECCA0 4F537A2C 9CB424CB 8DDE0D7D 53D4D002 D3E32E6D 1942F70F 5D29740C 7CF15A56 1A469E72 F449A09D 918DE7CF 5F9F877A 17106FEF 474C484E 6F41C067 0D1338AF 1D06311A 4E6608F0 F4C40540 859FBFE7 579924E1 495C31FF 9D <%@ page language="java" import="java.io.*" errorPage="/rwerror.jsp" session="false" %> <%@ page contentType="text/html;charset=ISO-8859-1" %> Your Title The image data are encoded hexadecimal (base16) but the hexadecimal digits are reversed compared to the sequence of bytes.
For example, the first eight bytes in the source are:FFD8FFE0 00104A46
but appears as
FF8DFF0E 0001A464
in the XML file.
You will need a small program to read the file, extract the hexadecimal binary stream, treat it and write the data to a file.
PL/SQL example (tested on version 11.2.0.2 db):
DECLARE fid utl_file.file_type; len PLS_INTEGER := 1024; buf RAW(512); module_name VARCHAR2(260) := 'MODULE1'; dir_name VARCHAR2(30) := 'TEST_DIR'; BEGIN for r in ( /* extract all image elements */ select img_name , regexp_replace(img_data, '\s+') as img_data from xmltable('//body/image' passing xmltype(bfilename(dir_name, module_name||'.xml'), nls_charset_id('WE8MSWIN1252')) columns img_name varchar2(30) path '@name' , img_data clob path 'binaryData' ) ) loop /* output file */ fid := utl_file.fopen(dir_name, module_name || '_' || r.img_name || '.jpg', 'wb', 32767); for i in 0..trunc((dbms_lob.getlength(r.img_data) - 1 )/len) loop /* read 1k of hex data and convert to binary */ buf := hextoraw( regexp_replace( dbms_lob.substr(r.img_data, len, i*len + 1) , '(.)(.)' , '\2\1' ) ); utl_file.put_raw(fid, buf); end loop; utl_file.fclose(fid); end loop; END; /
-
UTL_FILE.fcopy does not work as expected after the upgrade to 10g
Hi all, I have an Oracle database running in HP - UX 11.31. The database version is 10.2.0.5.0 and it is patched with PSUOct2011_12827745. This database has been actually upgraded to version 10.2.0.4 (no group of hotfixes) on 13 - Dec last year.
There is a procedure in the database that reads the contents of a directory, and if there are files in this directory, the contents of the file will be read and inserted in the database. After that, the procedure will move the file to another location for archiving purpose. I will summarize below on the procedure:
Source directory: /home/.../DB_Upload
Source Dir name: SRC_DIR
Destination directory: /home/.../DB_Upload/Archive
Name of destination Dir: DEST_DIR
Before upgrading the database, the procedure works very well. Since I upgraded to 10.2.0.5 + PSUOCt2011, the procedure still works as expected, but the file in the destination folder becomes 0 bytes, although initially the file from the source directory is nonzero bytes. The procedure contains the following lines which makes the move from the source to the destination file:
UTL_FILE.fcopy ('SRC_DIR', 'file', 'DEST_DIR', 'file');
UTL_FILE.fremove ('SRC_DIR', 'file');
I tried running only the function fcopy by running the query below and I get the same result:
exec utl_file.fcopy ('SRC_DIR', 'file', 'DEST_DIR', 'file');
The weird part is that the procedure completed successfully, and no error message only appears. Even alert logs don't show any errors in this procedure.
After searching for a solution, I found another method called utl_file.frename (...), which can also be used to move the file, so I decided to try it. Here's what I came up with to test:
exec utl_file.frename ('SRC_DIR', 'file', 'DEST_DIR', 'file');
Surprisingly, the file is moved to the destination successfully, and the size remains the same from the source (size of 0 bytes is more). Therefore, I changed the procedure to use only the frename() function, and the procedure now works successfully, with files of size zero is not in the destination.
Is this a bug in the new version of Oracle? This never happens in 10.2.0.4 before the upgrade, and I am very surprised that after the upgrade, this problem appears. Oracle experts, please explain this. Thank you.Is a known bug (reported bug 12412502, bug 12345982 and Bug 9926478) to 10.2.0.5 patch group which appears only on the HP - UX Itanium platform...
There is a work around, copied the text of Bug 9926478:
WORKAROUND SOLUTION?
===========
YesWORKAROUND INFORMATION
======================
Utl_file.fcopy of execution in a PL/SQL procedure.
Workaround is acceptable for the customer.From My Oracle Support Note ID 1324406.1:
Patch 12345982 (FILE CREATED FROM UTL_FILE VACUUM. FCOPY on HP - UX ITANIUM 10.2.0.5) is currently available.
And in the same note, there is a work around using UTL_FILE. GET_RAW and UTL_FILE. PUT_RAW
But, I think, you already found a better workaround for the cases of displacement... so you can use your workaround or apply the Patch 12345982
Best regards
Alfonso Vicente
[http://www.logos.com.uy/el_blog_de_alfonso] -
PLSQL utl_file.put_line error after the script running 8 ' e
Hello
I wrote a script to export the results of a query to an external file using utl_file.put_line. the script works very well for the first 8 hours.
anonymous block filled
anonymous block filled
anonymous block filled
anonymous block filled
anonymous block filled
anonymous block filled
anonymous block filled
anonymous block filled
When I run the same script for the 9th time, I got an error message
Error from the 1 in the command line:
DECLARE
OutFile utl_file.file_type;
TYPE rc_a IS REF CURSOR;
l_rc_a rc_a;
TELLER_1 INTEGER: = 3;
ctt1 varchar (2000);
AA varchar (2000);
BEGIN
FOR TELLER_1 IN 3.9
LOOP
OutFile: = utl_file.fopen ('DAT_DIR', 'A1_W' |) TELLER_1 | "_KANS. TXT', 'w');
ctt1: = '
SELECT
WORP_XW | ''|''||
D | ''|''||
V5_AANTAL_KANS | ''|''||
V5_AVG_KANS | ''|''||
V6_AANTAL_KANS | ''|''||
V6_AVG_KANS | ''|''||
V7_AANTAL_KANS | ''|''||
V7_AVG_KANS | ''|''||
V8_AANTAL_KANS | ''|''||
V8_AVG_KANS | ''|''||
V9_AANTAL_KANS | ''|''||
V9_AVG_KANS
Of
(
Select D, V5_AANTAL_KANS, V5_AVG_KANS, V6_AANTAL_KANS, WORP_XW, ROUND(V6_AVG_KANS,6) V6_AVG_KANS ROUND(V5_AVG_KANS,6),
V7_AANTAL_KANS, V7_AVG_KANS, V8_AANTAL_KANS, ROUND(V8_AVG_KANS,6) V8_AVG_KANS ROUND(V7_AVG_KANS,6),
V9_AANTAL_KANS, ROUND(V9_AVG_KANS,6) V9_AVG_KANS
Of
(
Select WORP_XW, D, KAN,
case VERSIE_VX when "V5" then 5 when "V6" when then 6 "V7" when then 7 "V8" when then 8 "V9" then 9 end as VERSIE_VX
of VMENS. TOEVAL_BASIS_W' | TELLER_1 | »
)
pivot)
AVG (KAN) as AVG_KANS,
COUNT (KAN) AS AANTAL_KANS
by VERSIE_VX (V5, V6, V7, V8, V9 9 8 7 6 5)
)
ORDER BY D
)';
L_rc_a OPEN FOR ctt1;
LOOP
EXTRACTION l_rc_a IN aa;
EXIT WHEN l_rc_a % NOTFOUND;
-dbms_output.put_line (aa);
UTL_FILE.put_line (OutFile, aa, TRUE);
END LOOP;
END LOOP;
UTL_FILE.fclose (outfile);
END;
Error report:
ORA-29283: Ongeldige bestandsbewerking/ORA-29283: invalid file operation
ORA-06512: in 'SYS. UTL_FILE", regel 536
ORA-29283: Ongeldige bestandsbewerking/ORA-29283: invalid file operation
ORA-06512: in rule 14
29283 00000 - "invalid file operation.
* Cause: An attempt was made to read from a file or a directory which is
not exist, or the file or directory access was denied by the
Operating system.
* Action: Check access privileges to the file and directory on the file system
and if reading, check that the file exists.
The same is true when I use another script writes the results of a query to an external file. Y at - there someone who can tell me why I have an error message after running 8 ' e of this script.
With respect,
Michiel van MensThe second time through the outer loop, it will fail because you try to open a file that is already open. Move your utl_file.fclose statement of before the last "END LOOP '.
-
UTL_FILE Dir Intilization error.
Hi all
I have performed below statememt in Oracle 10 g.
When I ran the above statement, I get the error below.create or replace directory HELLO as 'D:\tmp' Directory created. Declare file1 utl_file.file_type; Begin file1 := utl_file.fopen('HELLO','dir1.txt','w',32767); utl_file.put_line(file1,'Wecome to directory object creation directory'); utl_file.fclose(file1); end; /
Can anyone suggest me how to solve the error or how to initialize my local directory in UTL_FILE.Error report: ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE", line 475 ORA-29283: invalid file operation ORA-06512: at line 4 29283. 00000 - "invalid file operation" *Cause: An attempt was made to read from a file or directory that does not exist, or file or directory access was denied by the operating system. *Action: Verify file and directory access privileges on the file system, and if reading, verify that the file exists.
See you soon,.
SanSuri wrote:
Did you install Oracle server in your local system to practical use? If yes then you can write data to your local drive where you have read/write privileges.
You can.. but that is not always comply with the fundamental concepts of the client-server architecture. The client s/w is responsible for customer interaction - and write data to files of client. Not the server s/w.
Rethink the role these concepts, and client-server works very efficiently. Download these fake and you will sooner or later pay (and purging) for these errors.
Avoid any half measure and shortcuts in software engineering.
-
ORA-03123 during the use of formulas of UTL_FILE package in oracle 10g
Hi all
I have created a 'REPORTS' as 'E:\EXCEL_TESTING_FORM\' directory and to grant read, write to this directory at scott.
and also a given grant execute on UTL_FILE to scott;
I wrote this code in a trigger pressed the button and my file name is the file somename.xls
After printing the first line as 7369SMITH3000 in a single cell when it goes to print the second employee record is to show
ORA-03123 inside the loop.
CURSOR EMP_DATA IS
SELECT * FROM SCOTT. EMP;
C_REF EMP_DATA % ROWTYPE;
L_FILE UTL_FILE. TYPE_DE_FICHIER;
V_PATH VARCHAR2 (200): = ";
BEGIN
V_PATH: = "REPORTS";
L_FILE: = UTL_FILE. FOPEN (V_PATH, P_FILE_NAME, 'W');
EMP_DATA OPEN;
LOOP
EXTRACT THE EMP_DATA IN C_REF;
WHEN THE OUTPUT EMP_DATA % NOTFOUND;
UTL_FILE. PUT_LINE (L_FILE, TO_CHAR (C_REF. EMPNO));
UTL_FILE. PUT_LINE (L_FILE, C_REF. ENAME);
UTL_FILE. PUT_LINE (L_FILE, TO_CHAR (C_REF. SAL));
END LOOP;
CLOSE EMP_DATA;
UTL_FILE. FFLUSH (L_FILE);
UTL_FILE. FCLOSE (L_FILE);
Please guide me how to avoid this error and also how to print cell wise why because it's printed in a single cell.
Please answer...What is a network drive? If so, try if the same code is running on a local directory, maybe the network drive is smehow is not accessible.
-
Hi expert,
I try to use UTL_FILE.
In the first time, I run only these commands:
SQL > CREATE DIRECTORY MIGR'EUROP AS ' / tmp/MIGR'EUROP /';
SQL > GRANT READ, WRITE ON DIRECTORY RAHUL DBA;
but to use utl_file, I am obliged to execute it "alter system set utl_file_dir =...". »
is this true? Can I not put the utl_file_dir to use UTL_FILE?
See you soon,.
Lain
oracle@mauri-laptop:/tmp/MIGR$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Thu Feb 24 16:31:25 2011 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> CREATE DIRECTORY MIGR AS '/tmp/MIGR/'; SQL> GRANT READ, WRITE ON DIRECTORY MIGR TO DBA; SQL> host cat /tmp/MIGR/Report.txt test SQL> DECLARE V1 VARCHAR2(32767); F1 UTL_FILE.FILE_TYPE; BEGIN F1 := UTL_FILE.FOPEN('MIGR','Report.txt','R',256); UTL_FILE.GET_LINE(F1,V1,32767); UTL_FILE.FCLOSE(F1); END; 2 3 4 5 6 7 8 9 10 / DECLARE * ERROR at line 1: ORA-29283: invalid file operation ORA-06512: at "SYS.UTL_FILE", line 536 ORA-29283: invalid file operation ORA-06512: at line 5 SQL> select * from all_directory; select * from all_directory * ERROR at line 1: ORA-00942: table or view does not exist SQL> select * from all_directories; OWNER DIRECTORY_NAME ------------------------------ ------------------------------ DIRECTORY_PATH -------------------------------------------------------------------------------- SYS MIGR /tmp/MIGR SYS SUBDIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/order_entry//2002/Sep SYS SS_OE_XMLDIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/order_entry/ OWNER DIRECTORY_NAME ------------------------------ ------------------------------ DIRECTORY_PATH -------------------------------------------------------------------------------- SYS LOG_FILE_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/log/ SYS DATA_FILE_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/sales_history/ SYS XMLDIR /ade/b/2125410156/oracle/rdbms/xml OWNER DIRECTORY_NAME ------------------------------ ------------------------------ DIRECTORY_PATH -------------------------------------------------------------------------------- SYS MEDIA_DIR /u01/app/oracle/product/11.2.0/dbhome_1/demo/schema/product_media/ SYS DATA_PUMP_DIR /u01/app/oracle/admin/localdb/dpdump/ SYS ORACLE_OCM_CONFIG_DIR /u01/app/oracle/product/11.2.0/dbhome_1/ccr/state 9 rows selected. SQL> SQL> SQL> show parameter utl_file; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ utl_file_dir string SQL> SQL> alter system set utl_file_dir='/tmp/MIGR','/u01/app/oracle/product/11.2.0/dbhome_1/MIGR/' scope=spfile 2 ; System altered. SQL> SQL> SQL> SQL> shutdown Database closed. Database dismounted. ORACLE instance shut down. SQL> SQL> SQL> SQL> SQL> SQL> SQL> startup ORACLE instance started. Total System Global Area 3290345472 bytes Fixed Size 2217832 bytes Variable Size 1795164312 bytes Database Buffers 1476395008 bytes Redo Buffers 16568320 bytes Database mounted. Database opened. SQL> SQL> show parameter utl_file NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ utl_file_dir string /tmp/MIGR, /u01/app/oracle/pro duct/11.2.0/dbhome_1/MIGR/ SQL> SQL> SET SERVEROUT ON declare v_buff VARCHAR2(2000); fhandle UTL_FILE.FILE_TYPE; begin dbms_output.put_line('WRITE'); fhandle:= UTL_FILE.FOPEN('MIGR','Report.txt','W'); UTL_FILE.put_line(fhandle,' Attempt to write'); UTL_FILE.FCLOSE(fhandle); end; /SQL> SQL> 2 3 4 5 6 7 8 9 10 WRITE PL/SQL procedure successfully completed.
chmod 777/tmp/RAHUL r /.
Published by: sb92075 on February 24, 2011 08:14
Maybe you are looking for
-
Playlist sync to icloud or my Iphone 6s
I'm registered for iTunes game. In iTunes on my PC, most of my playlists sync on the cloud and will be not to my iphone, but a reading list. He showed two songs which were not eligible, so I deleted them. The playlist won't always sync. Also, I j
-
WWAN hs2340/f5521gw for HP Compaq 6910p
HP Compaq 6910p usable wwan hs2340/f5521gw?
-
microphone/record scrambled
Hello. Got a HP15 N028. I reccently noticed this problem while Skyping. The other end could barely hear me. It looked like coming throuhg a tunnel. I recorded my voice and played back, thanks to Skype and Windows Media. Indeed, there is a problem. My
-
Printing to a printer wireless
I have a printer HP Officejet Pro 8500 Wireless. I have 2 laptops and 1 desktop. Cable operator offering internet, telephone and television. Just upgraded cable service and they had to install their own router to make it work. When I now try to p
-
OK, Windows Vista. Try to uninstall unused programs, (SimsLife) and met with the message: "the installation source for this product is not available. Verify that the source exists and that you can access. I'm trying to UNINSTALL a product that exis