Runtime error using utl_file package
Hi Friends,
This is the procedure for reading sample data from flat file , but it won't work.
create or replace procedure test_utl_file
is
ftype utl_file.file_type;
ch varchar2(200);
begin
ftype := utl_file.FOPEN('C:\oracle\temp','data.txt,R');
utl_file.get_line(ftype,ch);
dbms_output.put_line(ch);
end;
This code is compiled succesfully , but at runtime it shows an error msg
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at "SCOTT.TEST_UTL_FILE", line 7
ORA-06512: at line 1
I had entered the directory entry in int.ora file
utl_file_dir=C:\oracle\temp
& i used another way also,
by using alter set utl_file_dir=C:\oracle\temp scope=spfile;
Can anyone help me to resolve this problem.
Rgrds,
Anand
What database version are you using?
The UTL_FILE_DIR parameter has been deprecated by oracle in favour of direcory objects because of it's security problems.
The correct thing to do is to create a directory object e.g.:
CREATE OR REPLACE DIRECTORY mydir AS 'c:\myfiles';
Note: This does not create the directory on the file system. You have to do that yourself and ensure that oracle has permission to read/write to that file system directory.
Then, grant permission to the users who require access e.g....
GRANT READ,WRITE ON DIRECTORY mydir TO myuser;
Then use that directory object inside your FOPEN statement e.g.
fh := UTL_FILE.FOPEN('MYDIR', 'myfile.txt', 'r');
Note: You MUST specify the directory object name in quotes and in UPPER case for this to work as it is a string that is referring to a database object name which will have been stored in uppercase by default.
Similar Messages
-
Error while using UTL_FILE package
I am getting error while using UTL_FILE package in apex 3.0 version
Pls help me out.ok, how are you using UTL_FILE and what is the error?
-
Creating Error log files using UTL_FILE package on a remote machine
Database Version: 10g Release2
OS Platform: Sun Solaris
I have been asked to log errors to OS files rather than tables. So, i wanted to use UTL_FILE package. But the client doesn't want to store these files on the same server where the database is running(as specified in UTL_FILE_DIR). Is there a way i could get these files created on a remote machine(client).I believe what others are suggesting is that your stored procedure continues to log to a table and a separate process be created that runs on the machine you want the file to be created on which reads the log table and writes to a log file.
If that is not an option, can you expose the directory on the remote machine you want to write the file to as a file share that can be mounted by the database server? If you can, you could write errors there using UTL_FILE. However, it would probably be a bad idea. If you're logging an error already, that implies that something has gone wrong. Making an error logging process dependent on a remote server being available and properly mounted with appropriate privileges at the instant the error occurs just creates more sources of failure that would prevent you from logging an error, which would prevent you from being able to debug the problem or even know it existed without a report from a user.
Justin -
Need to generate the excel file with diffrent sheets using utl_file package
Hi,
Sorry for previous message in which I had missed the usage of " UTL_FILE " package
I need to generate the excel file with diffrent sheets . Currently I am generating the data in three diffrent excel files using
" UTL_File " package and my requirement is to generate this in a single excel file with diffrent sheets.
Please help on this
Thanks & Regards,
Krishna VyavahareHello 10866107,
at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the packages behind second and fourth link support more than one worksheet.
Regards
Marcus -
Permissions on files created using UTL_FILE package
The files created on unix using UTL_FILE package have permisisons rw- - - - - - -.(600). I want them to be created with permissions 640.(rw-r - - - - - ).i.e read access to the group also. The umask setting of the unix account of the oracle instance are 137. Is there any way to create the files with the required permissions.
So SQL*Plus is on your PC? I'm assuming you mean 'call' as in the windows cmd.exe command?
Sheesh this is like getting blood from a stone.
In that case you must be connecting via the listener and not internally.
In which case the umask comes from the umask that was set in the environment of the OS user who started the listener process.
Thats not necessarily the same as the owner of the oracle software (normally 'oracle').
If sysdamin joebloggs logs in and starts the listener manually in a shell, then the umask applied to all shadow processes started by the listener is whatever jobloggs umask was when he typed the command 'lsnrctl start'. The umask of the owner of the oracle software, or your umask, is utterly irrelevent.
So if you don't like the umask for files created by processes spawned by the listener, stop and restart the listener in a shell where you have explicitly set the umask to what you want it to be.
Really starting the listener should be scripted and the correct umask is put in the script just before the call to 'lsnrctl start'. -
Archiving files generated by PL/SQL program using UTL_FILE package
Dear All,
We have on PL/SQL package that is generating some data files using UTL_FILE package in one specific directory.
I am working on concurrent program of type host(unix script) to move generated file to some archive folder.
Now the problem is owner of the files generated by PL/SQL is oracle and file permissions of the generated files are 644(Only read permission for group and others).
Concurrent program is using an another os user applmgr to execute the script attached with concurrent program.
Because applmgr is not having write permission on the files, hence mv command is failing.
Please suggest me how to resolve this issue.
Regards
Devender YadavHi;
I just think that, you can create one sh which is chancing permission of related path owner for applmgr user and put it on crontab and it can run every 1 min.
Regard
Helios -
Create a file and store it in the database using UTL_FILE package
Hello.
I'm using UTL_FILE package to store data from a table into an excel file but I don't know how to store this file in a table with a BLOB field the database at the same time. I want do do this because I will use it in a Oracle Portal.
Anybody has any idea how to do this?
Thanks & Regards,
AlexandraFrom Asktom
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:232814159006 -
Portal Runtime Error - CRM Business Package
Hi,
I've have installed Business Package for SAP CRM 4.0 60.2.3 onto my Netweaver Portal. My Netweaver Portal version is EP7.0 SP10. My SAP CRM version is CRM 5.0. I've also done the connectivity test for both Connector and Web AS. Both connection results are successful.
However, when I go to Portal to see the CRM iViews, it gives me an error as follow (this is one of them):
Portal Runtime Error
An exception occurred while processing a request for :
iView : pcd:portal_content/com.sap.portal.migrated/ep_5.0/roles/com.sap.pct.crm.container.SapCRM40.All/PartnerMngrCC/SrvCtr/Service/com.sap.pct.crm.channelmgmt.service
Component Name : null
Page could not create the iView.
See the details for the exception ID in the log file
I look into the log file, it says:
User PIAFUSER, IP address
HTTP request processing failed. HTTP error [403] will be returned. The error is [You are not authorized to view the requested resource.No details available].
If given SAP_ALL profile to PIAFUSER.
Appreciate any help on this.
Rgds,
Hapizorr Rozi AliasHiya,
first off, if your backend is CRM 5.0 you should use the BP for CRM 5.0 instead of the 4.0 one.
As you know, in SAP NetWeaver 2004s, the portal is installed as a usage type via SAPINST. Now for installing the Business Package for CRM 5.0 there's a SAP note because the installation process also goes via SAPINST.
Check out SAP Note 883948. The following sections should be particularly helpful:
Section PREPARATION -> Components of BP CRM (UT Code: BP-CRM)
Section INSTALLATION, esp. info on JSPM
Best regards
Dagmar. -
Samples using UTL_FILE package
hello;
I would like to use the utl_file package: fopen, put_line ...
can you send me some samples using this package.
thanks to your help
mam
nulldeclare
T1 UTL_FILE.FILE_TYPE;
begin
begin
T1:= UTL_FILE.FOPEN
('/u02/applmgr/10.7p161/eye/3.3.1/out','filename.dat','w');
EXCEPTION
WHEN UTL_FILE.INVALID_PATH THEN
DBMS_OUTPUT.PUT_LINE('Invalid Path');
WHEN UTL_FILE.INVALID_MODE THEN
DBMS_OUTPUT.PUT_LINE('Invalid Mode');
WHEN UTL_FILE.INVALID_OPERATION THEN
DBMS_OUTPUT.PUT_LINE('Invalid Operation');
end;
UTL_FILE.PUT(T1,'PROD DATE ');
UTL_FILE.PUT(T1,'PRODUCT ');
UTL_FILE.PUT_LINE(T1,'INTEREST TYPE ');
UTL_FILE.PUT(T1,'LEASE NUMBER ');
begin
UTL_FILE.FCLOSE(T1);
EXCEPTION
WHEN UTL_FILE.WRITE_ERROR THEN
DBMS_OUTPUT.PUT_LINE('write error');
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
DBMS_OUTPUT.PUT_LINE('Invald File Handle');
end;
END;
mamoudou (guest) wrote:
: hello;
: I would like to use the utl_file package: fopen, put_line ...
: can you send me some samples using this package.
: thanks to your help
: mam
null -
*Runtime error: 91* (DM package)
Hi friends,
i'm trying to run data manager package through a command button, macro i used is MNU_EDATA_RUNPACKAGE.
But when i click on that system prompting with message
Runtime error: 91
"Object variale or with block variable not set".
Or other error message like
*Cannot run this macro "reportname!MNU_EDATA_RUNPACKAGE". The macro may not be available in this workbook or all macros may be disabled.
I enable all macros and cheked tick mark trust access to vba project object model(in macro security).
Is there any macro in bpc nw75, to run only particular package using command button?
thanks.Now not getting this error. don't know answer .
-
Error using dbms_redefinition package
Hi,
I am trying to use dbms_redefinition package to add a column to a table using primary key method
SQL> conn / as sysdba
Connected.
SQL> grant execute on sys.dbms_redefinition to hr;
Grant succeeded.
SQL> grant dba to hr;
Grant succeeded.
SQL> conn hr/<password>
Connected.
SQL> create table tab1(roll_no number constraint roll_pk primary key,last_name varchar2(30));
Table created.
SQL> insert into tab1 values (1,'Hall');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into tab1 values (2,'Mall');
1 row created.
SQL> commit;
Commit complete.
SQL> insert into tab1 values (3,'Roll');
1 row created.
SQL> commit;
Commit complete.
Adding required column
SQL>
SQL> alter table tab1 add(first_name varchar2(30));
Table altered.
Checking if table can be redefined
SQL> exec dbms_redefinition.can_redef_table('HR','TAB1',DBMS_REDEFINITION.CONS_USE_PK);
PL/SQL procedure successfully completed.
Creating interim table
SQL> create table tab2 as select roll_no,first_name,last_name from tab1 where 1=2;
Table created.
Adding primary key to interim table
SQL> alter table tab2 add constraint roll_pk_1 primary key (roll_no);
Table altered.
Starting redefinition :
SQL> exec dbms_redefinition.start_redef_table('HR','TAB1','TAB2','ROLL_NO,FIRST_NAME,LAST_NAME');
BEGIN dbms_redefinition.start_redef_table('HR','TAB1','TAB2','ROLL_NO,FIRST_NAME,LAST_NAME'); END;
ERROR at line 1:
ORA-00439: feature not enabled: Advanced replication
ORA-06512: at "SYS.DBMS_REDEFINITION", line 52
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1646
ORA-06512: at line 1
SQL>
Could you please help.
Thanks,
HaiderYou can, yes. That's why CAN_REDEF_TABLE and START_REDEF_TABLE both have an OPTIONS_FLAG argument that lets you specify whether you want to use the primary key or the ROWID to redefine the table.
SQL> drop table foo;
Table dropped.
SQL> create table foo( col1 number, col2 number );
Table created.I can't redefine the table using the primary key since there is no primary key
SQL> ed
Wrote file afiedt.buf
1 begin
2 sys.DBMS_REDEFINITION.CAN_REDEF_TABLE ( 'SCOTT', 'FOO' );
3* end;
SQL> /
begin
ERROR at line 1:
ORA-12089: cannot online redefine table "SCOTT"."FOO" with no primary key
ORA-06512: at "SYS.DBMS_REDEFINITION", line 139
ORA-06512: at "SYS.DBMS_REDEFINITION", line 1782
ORA-06512: at line 2But I can use the ROWID
SQL> ed
Wrote file afiedt.buf
1 begin
2 sys.DBMS_REDEFINITION.CAN_REDEF_TABLE ( 'SCOTT', 'FOO', dbms_redefinition.cons_use_rowid );
3* end;
SQL> /
PL/SQL procedure successfully completed. Justin -
Writing files using UTL_FILE package
Greetings:
I'm attempting to write simple text files on the server side using the UTL_FILE package.I can get it to write the file to a local drive on the Oracle server with no problems, but not a network drive. When trying to write to a network drive, the FOPEN function raises the UTL_FILE.INVALID_OPERATION exception. This is even with my UTL_FILE_DIR parameter set the * for all directories and I have "Full Control" permission on the directory. I am running in a NT Server/Wkstn environment. Anyone have any ideas why I can't write a file to a network drive?
Thanks a lot,
Chris ScoppThanks for your response...
I have set the UTL_FILE_DIR parameter... I've tried setting it to the * for all directories and also mapping a drive letter from the server to where I want to write the file and then explicitly naming this path in the UTL_FILE_DIR parameter. Neither works, I still get the INVALID_OPERATION exception raised on the FOPEN function. I'm convinced now that it does have something to do with NT because I have been able to do the same operation writing to a Win95/98 box and it works fine. I have "Full Control" to all places I'm trying to write to, any other ideas?
Thanks a lot,
Chris Scopp -
Reading all files on directory using "utl_file" package...
I need to read all files in directory via PL/SQL. I don't know
name files (are data dynamics create for automation system),
only I know your extensions.
Can I do this using the package "utl_file" or I need to create
program in another language (C, C++, for example)?
Any ideas...
Thanks.Hi,
you can't do that with the UTL_FILE package (it can't retrieve
file names).
A very simple solution would be, if you created on OS-level a
file which contains the filenames of directory and then read this
file using UTL_FILE. With the information on all file names you
can enter a loop which opens and reads all files again using
UTL_FILE.
A more mundane solution could be to use the features on the iFS.
Cheers
Gerald -
Unable to write files in different m/c in LAN using utl_file package
I need to dump some files generated by utl_file package in a separate m/c not in the db server.For that I tried using utl_file_dir='*' and mapped the specified directory in the db server. but its failing as show below..
ORA-29283: invalid file operation
ORA-06512: at "SYS.UTL_FILE", line 449
ORA-29283: invalid file operation
ORA-06512: at "ANIRBAN.WRITE_IN_FILE", line 9
ORA-06512: at line 1
The prototype sp is given below..
CREATE OR REPLACE PROCEDURE write_in_file(pInDir IN VARCHAR2,
pInFileName IN VARCHAR2,
pInFileContent IN VARCHAR2) IS
vFile UTL_FILE.FILE_TYPE;
vFileName VARCHAR2(20) := pInFileName;
BEGIN
dbms_output.enable(1000000);
vFile := UTL_FILE.FOPEN(pInDir, vFileName, 'w', 32000);
UTL_FILE.PUT_LINE(vFile, pInFileContent);
UTL_FILE.FCLOSE(vFile);
END write_in_file;
With this sp i'm able to write in genuine drives but not in mapped one.What shall be done to be able to write in a separate m/c freely.Plz guide meAnd make sure you specify the full path name of the server/directory path rather than using substituted drive names as is can sometimes be funny about that sort of thing.
-
Runtime error using range table in select query
I have to select tcodes from table tstc, based on the entries in ust12,
the entries in ust12-von and ust12-bis, these contains wild charcters also, and i have to selct all the tcodes from von to bis.
so ia m preparing a range table for the entries in ust12, and querying table tstc, then i am getting a runtime error with following description.
'If the problem occurred because an excessively large table was used
in an IN itab construct, you can use FOR ALL ENTRIES instead.'
but how can i use FOR ALL ENTRIES here, because if von = A* and bis = AB*,then i ahve to read all the entries from AAAA till ABZZ (may be something like this),
is there any way to write this query, with out runtime error.
there are total 15000 entries in ust12, i am preparing range table for 3000 entries each and querying tstc.
Thanks in advance
Best Regards
Amarender Reddy BHi,
first write a select on ust12 based on ust12-von and ust12-bis.
eg: select von bis from ust12 into table gt_ust12
where von LIKE 'A%'
and bis LIKE 'AB%'.
now write another select for tstc for all entries in gt_ust12...
Hope it helps
Regards,
Pavan
Maybe you are looking for
-
Hi, My Data flow has 4 dso's and 1 cube. There are some common fields in 4 dso's. It was a 3.5 flow and I have migrated to BI7.0. SOme of the mapping were proposed by itself but some are not. Now my question is How the data would be viewed at query l
-
My JMS cannot dequeue the aq in DB (Exception JMS-120)
When debug throw the statement receiveNoWait(),it throw out exception JMS-120 dequeue failed,who can tell me why? My method as below: public void test() QueueConnectionFactory qcfact; QueueConnection qconn; QueueSession session; Queue queue
-
Set subject in incident using BADI
Hi Experts I'm working with solution manager 7 and I'm trying to set the Subject field based on some rules using BADI ORDER_SAVE, method CHECK_BEFORE_SAVE but I can't find a FM to set that field, I tried with CRM_SUBJECT_CHANGE_OW but it didn't work.
-
Imported files (from vhs to digital camcorder) are too big to handle.
When I import my vhs footage (through camcorder) to imovie... the files are so big they take most of my hard drive. For example the size is about 2GB for a minute of footage. Any ideas why? Thanks!! G5 Mac OS X (10.4.8)
-
ORA-12899 while trying to update Metalink credential on OEM 10.2.0.4
Hi, My Oracle DBMS version is 10.2.0.4 (non-Grid) on SUN/SPARC 64. I tried to add my metalink credential (which is 32 character long) to the 'Patching Setup' section but bumped into ORA-12899: value too large for column "SYSMAN"."MGMT_ARU_CREDENTIALS