Fclose problem
Hi,
i am exporting data from forms to client csv.. after the fclose statment i use cmd to open the file in excel but it seems still to be locked, the message that the file is used by another user...
pls help
I've had the same problem using fclose in the webutil library. It doesn't close the file immediatley. You can force the file to close by using SYNCHRONIZE or PAUSE after the fclose.
Similar Messages
-
Problem: DLL using fclose doesn't close file unless exit Labview completly
Hello,
Do I have more than one option to do this correctly? I do not want to be forced to stop and start
my Labview application every time I want to close a file.
Thank you,
Christopher LusardiLabView is calling the DLL from a Call Function Node.
The DLL is a copy of the below code. Is there anything wrong with this code?
Christopher Lusardi
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
char file [100];
#include "my_header.h"
int create_file ()
char Location [100] = "my_files/";
FILE *Fptr;
char box [50];
int numalo = 0;
int numdalo = 0;
int mypid;
int element;
if ( gethostname (box, 50) < 0 )
printf ("gethostname failed\n");
return (-1);
mypid = (int)getpid ();
sprintf (file,"%s%s_%d",Location,box,mypid);
if ( (Fptr = fopen (file,"w+")) == NULL )
printf ("fopen () failed opening file = %s\n",file);
return (-1);
else
fprinttf (Fptr,"%d\n",Number_of_items);
fprinttf (Fptr,"^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
for (element = 0; element < Number_of_items;element++)
if ( vegetable [element] == 1024 )
fprintf (Fptr,"%d %d %X %d %d %X %X %X\n",
vegetable [element],
fruit,
filtered_water.tomato [element],
filtered_water.green [element],
filtered_water.bacteria [element],
filtered_water.organic [element],
filtered_water.raw [element],
filtered_water.washed [element]);
else
fprintf (Fptr,"%d %d %X %d %d %d %X %X\n",
vegetable [element],
fruit,
filtered_water.tomato [element],
filtered_water.green [element],
filtered_water.bacteria [element],
filtered_water.organic [element],
filtered_water.raw [element],
filtered_water.washed [element]);
fclose (Fptr);
return (0);
<!--
document.write("<img id=ti751eff3a80e72ebb border=0 src=\"/img/r.gif\" height=11 width=... -
Problems with moving files to ora directory UTL_FILE.PUT_RAW - ORA-29285
hi,
i'm using apex 4.1
i have a procedure which moves my file from apex_application_files to ORA directory.
if i choose a text file or small word document which is 1kb, it works. but if i have pdf file (85kb) or word document (16kb) it gives me ORA-29285: file write error
what's my problem?
PROCEDURE put_file_to_server (p_filename IN VARCHAR2,p_cert_type IN VARCHAR2,p_cert_pk IN NUMBER)
AS
l_file UTL_FILE.file_type;
l_blob_len INTEGER;
l_pos INTEGER := 1;
l_amount BINARY_INTEGER := 32767;
l_buffer RAW (32767);
v_new_filename VARCHAR2(100);
v_bfile BFILE ;
BEGIN
-- delete from apex_application_files;
--Neuen Dateinamen generieren
v_new_filename := p_cert_type||'_'||p_cert_pk;
v_bfile := BFILENAME (v_directory, v_new_filename);
--Datei erstellen
l_file := UTL_FILE.fopen(v_directory,v_new_filename,'w');
IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
FOR rec IN (select blob_content lblob from apex_application_files where rownum = 1)
LOOP
l_blob_len := DBMS_LOB.getlength(rec.lblob);
cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '||l_blob_len);
WHILE l_pos < l_blob_len LOOP
DBMS_LOB.read (rec.lblob, l_amount, l_pos, l_buffer);
UTL_FILE.put_raw (l_file, l_buffer, FALSE);
l_pos := l_pos + l_amount;
END LOOP;
COMMIT;
END LOOP;
--Datei schließen
UTL_FILE.fclose(l_file);
else
cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesn't exist');
end if;
EXCEPTION
WHEN OTHERS
THEN
-- Close the file if something goes wrong.
IF UTL_FILE.is_open (l_file) THEN
UTL_FILE.fclose (l_file);
END IF;
delete from apex_application_files;
RAISE;
delete from apex_application_files;
END put_file_to_server;Sorry but din't test this...Can you give it a try and see if this works?
PROCEDURE put_file_to_server(
p_filename IN VARCHAR2,
p_cert_type IN VARCHAR2,
p_cert_pk IN NUMBER)
AS
l_file UTL_FILE.file_type;
l_blob_len INTEGER;
l_pos INTEGER := 1;
l_amount BINARY_INTEGER := 32767;
l_buffer RAW (32767);
v_new_filename VARCHAR2(100);
v_bfile BFILE ;
vblob BLOB;
vstart NUMBER := 1;
my_vr RAW(32000);
bytelen NUMBER := 32000;
LEN NUMBER;
BEGIN
-- delete from apex_application_files;
--Neuen Dateinamen generieren
v_new_filename := p_cert_type||'_'||p_cert_pk;
v_bfile := BFILENAME (v_directory, v_new_filename);
--Datei erstellen
--l_file := UTL_FILE.fopen(v_directory,v_new_filename,'w');
l_file := UTL_FILE.fopen(v_directory,v_new_filename, 'WB', 32760);
IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
FOR rec IN
(SELECT blob_content lblob,
LENGTH(blob_content) LEN
FROM apex_application_files
WHERE rownum = 1
LOOP
cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '|| LEN);
IF LEN < 32760 THEN
utl_file.put_raw(l_file,lblob);
utl_file.fflush(l_file);
ELSE -- write in pieces
vstart := 1;
WHILE vstart < LEN
LOOP
dbms_lob.read(vblob,bytelen,vstart,my_vr);
utl_file.put_raw(l_file,my_vr);
utl_file.fflush(l_file);
-- set the start position for the next cut
vstart := vstart + bytelen;
-- set the end position if less than 32000 bytes
x := x - bytelen;
IF x < 32000 THEN
bytelen := x;
END IF;
END LOOP;
END IF;
END LOOP;
ELSE
cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesnt exist');
END IF;
utl_file.fclose(l_file);
EXCEPTION
WHEN OTHERS THEN
-- Close the file if something goes wrong.
IF UTL_FILE.is_open (l_file) THEN
UTL_FILE.fclose (l_file);
END IF;
DELETE FROM apex_application_files;
RAISE;
DELETE FROM apex_application_files;
END put_file_to_server;Edited by: Vitor Rodrigues on 17/Fev/2012 12:03 -
Problem opening device from Java on Windows XP
Hi,
I am having trouble opening the TUN device (it is a virtual network device developed by the OpenVPN project - http://openvpn.net) from Java on Windows.
I found from the registry that the key for the device on my machine is
{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.
From elsewhere on the web, I found that on Windows this device can be
addressed as \\.\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap
I then wrote up a short C code,
char *tun_dev_name = "\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap";
FILE *f = fopen(tun_dev_name, "rw");
fclose(f);
HANDLE h = CreateFile(tun_dev_name, GENERIC_WRITE | GENERIC_READ, 0, 0, \
OPEN_EXISTING, FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_OVERLAPPED, 0);
CloseHandle(h);In the above code, the FILE* returned is non-NULL and the HANDLE returned is positive.
However, when I try to do the same in Java using the code below,
String tun_dev_name =
new String("\\\\.\\{5998ABF4-70CC-4B8C-9CBF-F2B985BAD4A2}.tap");
RandomAccessFile raf = new RandomAccessFile(tun_dev_name, "rw");
[]/code]
a "java.io.IOException: Invalid argument" is thrown. The same exception is thrown when I try to open either FileInputStream or FileOutputStream instead of RandomAccessFile.
In fact, when I invoke the above C code as a native method from within Java,
though a valid HANDLE is still returned, the FILE* returned is now NULL. I
have tried giving all permissions to my codebase using Java's policytool, but that didn't help. BTW, I ran all this code on Windows XP from cygwin.
Clearly this problem isn't with OpenVPN because I'm able to open the device using both fopen and CreateFile from C. Please let me know if one of you knows what the problem could be and what I need to do to fix it. In case, this is not the right forum for this question, kindly let me know which other forum I should pose this question on.
Thanks!
HarshaI am sorry but looks like somehow some text got missed out from my message.
After the C code and before the Java code, I had intended to mention that when that C code is compiled and run independently, both the fopen and CreateFile calls work fine, with a non-NULL FILE* and a valid HANDLE being returned, respectively.
And as I have already mentioned, when I invoke the C code as a native method from within Java, the CreateFile still works but the fopen fails returning NULL.
Sorry for missing that out. Hope somebody will be able to help me out.
Thanks!
Harsha -
Problem with reports in excel (using text_io)
we are using Report Builder 6.0.5.28.0 with Oracle9i Enterprise Edition Release 9.2.0.1.0. in a client/server evironment. I'm using 'TEXT_IO' to write the report output to a csv file.
The process runs ok but the only problem is that the first line of every page (other than the first) gets repeated.
can anyone out there tell me how to get over this problem.
Thanx in advance
Adolph1. You first need to create a package in your report
PACKAGE conv_text IS
procedure fopen(fname varchar2);
procedure fclose(fname varchar2);
procedure fwrite_c(fname varchar2,
var_c varchar2);
procedure fline;
END;
PACKAGE BODY conv_text IS
o_file TEXT_IO.FILE_TYPE;
filename VARCHAR2(50);
procedure fopen (fname varchar2) is
begin
filename := fname;
o_file := TEXT_IO.FOPEN(filename,'W');
end;
procedure fclose (fname varchar2) is
begin
Text_IO.Fclose(o_file);
end;
procedure fwrite_c (fname varchar2, var_c varchar2) is
begin
Text_IO.Put(o_file,var_c);
end;
procedure fline is
begin
Text_IO.New_Line(o_file);
end;
2. In the "before report trigger" open the csv file (make sure the folder exists on the client m/c)
conv_text.fopen(:filename);
3. In the innermost frame(use the following,for all the fields u want in ur csv file) :
filename VARCHAR2(50);
begin
filename := :filename;
conv_text.fwrite_c(filename,:agency_name);
conv_text.fwrite_c(filename,',');
conv_text.fwrite_c(filename,:invoice_no);
conv_text.fwrite_c(filename,',');
conv_text.fline;
4. In the after report, close the file
conv_text.fclose(:filename);
good luck and let me know if get thru with the problem of the repeating record.
Adolph
[email protected] -
Problem with UTL_FILE (please see my last post on this thread)
Hi all,
I'm trying to get the code (procedures, functions, etc) of my schemas. I've tried it using DBMS_METADATA.GET_DDL but it fails with many objects. Finally, I'm trying to create a procedure to extract the code.
I've created this two procedures:
CREATE OR REPLACE PROCEDURE spool_code (code IN varchar2, propi IN varchar2) is
CURSOR codigo is
select text from dba_source where name = code and owner = propi order by line;
line varchar2(4000);
BEGIN
open codigo;
loop
fetch codigo into line;
exit when codigo%notfound;
dbms_output.put_line(line);
end loop
close;
END;
CREATE OR REPLACE PROCEDURE ext_codigo is
CURSOR objeto is
select object_name, owner from dba_objects where object_type in ('PROCEDURE','FUNCTION','PACKAGE')
and owner not in ('OUTLN','DBSNMP','SYSTEM','SYS','REPADMIN','PERFSTAT','SPOTLIGHT','MONITOR','PRUEBAS','TOAD')
and status='VALID';
nom varchar2(128);
owner varchar2(30);
BEGIN
open objeto;
loop
fetch objeto into nom, owner;
exit when objeto%notfound;
spool_code(nom, owner);
end loop;
close objeto;
END;
And I'm calling from sqlplus to spool it:
SQL> spool Users_code.sql
SQL> exec ext_codigo;
But it don't bring me results...
where is the problem??
Thanks in advance for your support!
dbajug
Edited by: dbajug on Aug 29, 2012 6:36 AMHi,
yes guys, I've set serverout on using the max limit but, always fails with:
ERROR at line 1:
ORA-20000: ORU-10027: buffer overflow, limit of 1000000 bytes
ORA-06512: at "SYS.DBMS_OUTPUT", line 35
ORA-06512: at "SYS.DBMS_OUTPUT", line 198
ORA-06512: at "SYS.DBMS_OUTPUT", line 139
ORA-06512: at "SYS.SPOOL_CODE", line 15
ORA-06512: at "SYS.EXT_CODIGO", line 17
ORA-06512: at line 1
I'm working with a 9i version trying to extract the code to migrate it to a 11g.
In order to avoid the buffer error, I've decide use the UTL_FILE package but I'm having another problem: my procedure now is this
CREATE OR REPLACE PROCEDURE spool_code (code IN varchar2, propi IN varchar2) is
CURSOR codigo is
select text from dba_source where name = code and owner = propi order by line;
line varchar2(4000);
out_file UTL_FILE.File_Type;
BEGIN
begin
out_file := UTL_FILE.Fopen('/export/home/oracle', 'Users_code.sql', 'w');
exception
when others then
dbms_output.put_line('Error opening file');
end;
open codigo;
loop
fetch codigo into line;
exit when codigo%notfound;
UTL_FILE.Put_Line(out_file, line);
end loop;
close codigo;
UTL_FILE.Fclose(out_file);
END;
The directory exists and the file too but fails with this error:
ERROR at line 1:
**ORA-29282: invalid file ID**
ORA-06512: at "SYS.UTL_FILE", line 714
ORA-06512: at "SYS.SPOOL_CODE", line 23
ORA-06512: at "SYS.EXT_CODIGO", line 17
ORA-06512: at line 1
any idea? about the reason? The file is a text file on the server:
ls -lrt /export/home/oracle/Users_code.sql
-rw-rw-r-- 1 oracle dba 0 Aug 29 14:43 /export/home/oracle/Users_code.sql
best regards,
dbajug -
Problem in using CLOB Data from a Data and exporting into File
Hi,
UTL_FILE Error Occured while using UTL_FILE with CLOB Data.
UTL_FILE: A write error occurred.
The Below Code is for reference:
DECLARE
C_AMOUNT CONSTANT BINARY_INTEGER := 32767;
L_BUFFER VARCHAR2(32767);
L_CHR10 PLS_INTEGER;
L_CLOBLEN PLS_INTEGER;
L_FHANDLER UTL_FILE.FILE_TYPE;
L_POS PLS_INTEGER := 1;
BEGIN
FILE_NAME:=UTL_FILE.FOPEN('EXPORT_DIR','EXPORT_FILE'||'.sql','W');
FOR C1_EXP IN (SELECT INSERT_STRING FROM EXPORTED_DUMP) LOOP
L_CLOBLEN := DBMS_LOB.GETLENGTH(C1_EXP.INSERT_STRING);
DBMS_OUTPUT.PUT_LINE('THE CLOB LEN '||L_CLOBLEN);
DBMS_OUTPUT.PUT_LINE('THE POSITION '||L_POS);
WHILE L_POS < L_CLOBLEN LOOP
L_BUFFER := DBMS_LOB.SUBSTR(C1_EXP.INSERT_STRING, C_AMOUNT, L_POS);
DBMS_OUTPUT.PUT_LINE('THE BUFFER IS '||L_BUFFER);
EXIT WHEN L_BUFFER IS NULL;
UTL_FILE.PUT_LINE(FILE_NAME, C1_EXP.INSERT_STRING);
L_POS := L_POS + LEAST(LENGTH(L_BUFFER)+1,c_amount);
END LOOP;
END LOOP;
UTL_FILE.FCLOSE(FILE_NAME);
EXCEPTION
WHEN UTL_FILE.INTERNAL_ERROR THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An internal error occurred.');
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: The file handle was invalid.');
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_MODE THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid open mode was given.');
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_OPERATION THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid operation was attempted.');
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.INVALID_PATH THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid path was give for the file.');
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.READ_ERROR THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: A read error occurred.');
UTL_FILE.FCLOSE_ALL;
WHEN UTL_FILE.WRITE_ERROR THEN
DBMS_OUTPUT.PUT_LINE ('UTL_FILE: A write error occurred.');
UTL_FILE.FCLOSE_ALL;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE ('Some other error occurred.');
UTL_FILE.FCLOSE_ALL;
END;Hi user598986!
OK, I understood that there is a problem with your code. But please would you be so kindly to tell us here what error exactly happens (the errormessage). Mabay after that someone will be able to help you.
yours sincerely
Florian W.
P.S. If you enclose your code into tags it will be shown formated. -
Problem in creating file on local machine
Hello everbody...
i m using forms and reports 6i
i m creating file out_file := Text_IO.Fopen(:filepath || '.csv', 'a'); using this command in before_report trigger. And closing file in after_report trigger.
here filepath is = \\IP address of local machine\d$\file name
now problem is that if i m giving IP address of local machine then its giving error ORA-39856.
And if i m giving IP address of server machine then it is going to create file on server machine from local machine.
Why its not creating file on client machine?
i think there r problems related to rights
can anyone has solution then please tell meyes in report there is report output and with that it also creating file in coding by
out_file := Text_IO.Fopen(:filepath || '.csv', 'w');
this open stmt is written in before report trigger
Below lines r written for each row thats fetch by report main query.
str := rpad(:apt_bil_no,8,' ') || ',' || lpad(:apt_bil_dt,10,' ') || ',"' ||
rpad(:supl_name,30,' ') || '",' || rpad(:supl_tin_no,11,' ') || ',' ||
rpad(:aptvat_hsn_no,10,' ') || ',' ||
lpad(ltrim(to_char((apt_amt2 - apt_vat_amt2),'999999990.00')),12,' ') || ',' ||
lpad(apt_vat_amt2,12,' ') || ',' ||
lpad(ltrim(to_char(apt_amt2,'999999990.00')),12,' ');
Text_IO.Put(out_file, str);
Text_IO.New_Line(out_file);
file is closing in after report trigger.
text_io.fclose(out_file);
now i wants to create this file on local machine.
yes using report server and its started window service.
can u have any idea? -
UTL_FILE, Extra CRFL's, possible OS interpretation problem.
Greetings,
DISCLAIMER:
I am an oracle noob so if I make a mistake in forum etiquette or have not checked all available documentation or have made an assumption that is incorrect ( or noobish ) or am unaware of a tool better suited to the task I am trying to accomplish..
Please don’t flame me, I am learning. Give me constructive replies and I will learn, I promise.
My environment: 10G XE DB running on Server 2k3. Developing in SQLDEV 1.54
I am attempting to dump the contents of a CLOB to a file on the OS disc. Due to formatting restrictions, the contents of the file written to disc must be EXACTLY the contents of the CLOB, character per-per character, verbatim.
Here is an example anon block that will give you the essentials of the way I am attempting to accomplish this:
DECLARE
l_clob CLOB ;
l_output_file utl_file.file_type;
BEGIN
l_clob := 'Hello my name is George!' || chr(13) || chr(10) ;
l_clob:= l_clob || 'Would you like to play a game?' || chr(13) || chr(10);
l_clob := l_clob || 'It will be fun, I promise..' || chr(13) || chr(10);
dbms_output.put_line( dbms_lob.getlength(l_clob));
l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
utl_file.put( l_output_file , l_clob );
utl_file.fflush( l_output_file);
utl_file.fclose( l_output_file );
utl_file.fclose_all;
END;
Here you can see where I put a few lines into my clob, I manually append the CRLF using the CHR function, since I cant accurately reproduce a non-printable character in a string value. This is important because the Clob I am attempting to write to disc contains CRLF’s as part of its data, these must be preserved. Also note that I am writing this to the file using utl_file.PUT not PUT_LINE, again, because the disk file must be the clob verbatim, I cant use put_line because it adds a “new line character” at the end of the data it writes.
Ignore the DMBS_OUTPUT line , I will get back to that in a bit.
I execute this bit of code and get a file text.txt. What I expected to see was:
“'Hello my name is George!
Would you like to play a game?
'It will be fun, I promise..”
What I actually got was:
!http://i594.photobucket.com/albums/tt22/GargleSpam/Temp001.jpg!
Looking at this in notepad++ we can expose the non-printable chars:
!http://i594.photobucket.com/albums/tt22/GargleSpam/Temp002.jpg!
Using notepad ++ we can see that an extra CR ( CHR(13)) has been pre-pended to the CRLF. We can confirm this is not an artifact of viewing this in notepad by looking at the file size of the output file and comparing it to the size of the clob.
The DBMS_OUTPUT line indicates ( in my test case) clob size of 87 characters. If you take the time to count you will see this is correct. 81 printable characters that we see, and the 6 non-printable chars to accomplish the CRLF’s.
However if we look at the file size:
!http://i594.photobucket.com/albums/tt22/GargleSpam/Temp003.jpg!
So that’s 87 + our 3 “ninja ” CR’s.
For my purposes this is a deal-breaking problem. The contents of my output file must be exactly the contents of my clob, byte for byte. So this extra CR is a big big problem.
Where is it coming from? I started thinking about the “new line character” that the PUT_LINE procedure uses and, had a hunch that perhaps since the DB is OS independent, it might be passing one of the non-printable chars to the OS as “new line” and letting the os worry about what that means on disk. With that in mind I did some further testing:
DECLARE
l_clob CLOB ;
l_output_file utl_file.file_type;
BEGIN
l_clob := 'Incoming lf->'|| chr(10) ;
l_clob:= l_clob || 'Incoming cr->' || chr(13);
clob:= lclob || 'Incoming CRLF->' || chr(13) || chr(10);
l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
utl_file.put( l_output_file , l_clob );
utl_file.fflush( l_output_file);
utl_file.fclose( l_output_file );
utl_file.fclose_all;
END;
This code results in:
!http://i594.photobucket.com/albums/tt22/GargleSpam/Temp004.jpg!
Looking at this it becomes obvious that the CHR(10) is being written to disc as TWO characters ( CR LF). So my assumption must be correct, that the DB is passing CHR(10) to the OS as “newline” and the OS ( Windows in my case ) is interpreting this as ‘CRLF.’
This makes sense since it seems to be widely known ( though not to me , I am shaky on this part ) that “newline” in unix is just CHR(10), and in windows its CHR(10)||CHR(13).
So I seem to have isolated my problem. Now finally my question.. How to I get around this?
Google searches and searches on this forum yeilded only marginal help, something about passing this file through an FTP server.. ?. The only marginal help was in post # 3298335. Nothing that really answers my question though.
Is there a setting my DBA can set to change this behavior? Is there a different way ( PLSQL) to write the file that might mitigate this? Don’t say put the DB on unix, that’s not an option.
Let me know what you think…
-VAFHi,
Also you should check that the directory name is enclosed between '. TEST_DIR is an Oracle directory object that maps a real directory path in the filesystem (check privileges).
Like:
DECLARE
l_clob CLOB;
l_output_file utl_file.file_type;
BEGIN
l_clob := 'Hello my name is George!' || CHR(13) || CHR(10);
l_clob := l_clob || 'Would you like to play a game?' || CHR(13) || CHR(10);
l_clob := l_clob || 'It will be fun, I promise..' || CHR(13) || CHR(10);
dbms_output.put_line(dbms_lob.getlength(l_clob));
l_output_file := utl_file.fopen('TEST_DIR', 'test.txt', ' W', max_linesize => 32767);
utl_file.put(l_output_file, l_clob);
utl_file.fflush(l_output_file);
utl_file.fclose(l_output_file);
END;Tip: to post formatted code you must enclose it between {noformat}{noformat} tags (start and end tags are the same).
Regards, -
Webutil Invoke_String problem
I've the following c function:
extern "C" __declspec( dllexport ) char cGreeting(char* value1, char* value2);
And follow PL/SQL code:
PACKAGE BODY SAMPLE IS
FUNCTION greeting(value1 IN OUT VARCHAR2, value2 IN OUT VARCHAR2) RETURN VARCHAR2 IS
greeting_func webutil_c_api.FunctionHandle;
greeting_params webutil_c_api.ParameterList;
greeting_param1 webutil_c_api.ParameterHandle;
greeting_param2 webutil_c_api.ParameterHandle;
greeting_return VARCHAR2(1000);
BEGIN
greeting_func := webutil_c_api.register_function('cClient.dll', 'cGreeting');
greeting_params := webutil_c_api.create_parameter_list;
greeting_param1 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, value1, 1000);
greeting_param2 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, value2, 1000);
greeting_return := webutil_c_api.Invoke_char('cClient.dll', 'cGreeting', greeting_params);
webutil_c_api.destroy_parameter_list(greeting_params);
webutil_c_api.deregister_function(greeting_func);
return greeting_return;
END greeting;
END SAMPLE;
When I invoke this function appears this error:
ERROR>WUL-911 [CApiFunctions.invokeCApi()] Unsupported return type for C DLL function
Does anyone know where is the problem?
Thank you.I've tried your sample. I´ve a forms and, when I push a button, throw the following code:
declare
myValue1 varchar2(20);
myValue2 varchar2(20);
greeting_func webutil_c_api.FunctionHandle;
greeting_params webutil_c_api.ParameterList;
greeting_param1 webutil_c_api.ParameterHandle;
greeting_param2 webutil_c_api.ParameterHandle;
greeting_return varchar2(1000);
file_type text_io.file_type;
BEGIN
greeting_func := webutil_c_api.register_function('cClient.dll', 'myGreeting');
greeting_params := webutil_c_api.create_parameter_list;
greeting_param1 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, myValue1, 20);
greeting_param2 := webutil_c_api.add_parameter(greeting_params, webutil_c_api.C_CHAR_PTR, webutil_c_api.PARAM_INOUT, myValue2, 20);
greeting_return := webutil_c_api.Invoke_String(greeting_func, greeting_params);
message(greeting_return);
webutil_c_api.destroy_parameter_list(greeting_params);
webutil_c_api.deregister_function(greeting_func);
EXCEPTION
WHEN OTHERS THEN
file_type := text_IO.Fopen('c:\Sign\DAP\samples\logs\log.txt', 'w');
text_io.put( file_type, tool_err.message);
text_io.fclose(file_type);
But the browser crash and print a file with the follow message:
An unexpected exception has been detected in native code outside the VM.
Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x102c233f
Function name=(N/A)
Library=C:\Program Files\Oracle\JInitiator 1.3.1.9\bin\JNIsharedstubs.dll
NOTE: We are unable to locate the function name symbol for the error
just occurred. Please refer to release documentation for possible
reason and solutions.
Current Java thread:
at oracle.forms.webutil.cApi.CPtr.getString(Native Method)
at oracle.forms.webutil.cApi.CApiFunctions.invokeCApi(CApiFunctions.java:827)
at oracle.forms.webutil.cApi.CApiFunctions.getProperty(CApiFunctions.java:131)
at oracle.forms.handler.UICommon.onGet(Unknown Source)
at oracle.forms.engine.Runform.onGetHandler(Unknown Source)
at oracle.forms.engine.Runform.processMessage(Unknown Source)
at oracle.forms.engine.Runform.processSet(Unknown Source)
at oracle.forms.engine.Runform.onMessageReal(Unknown Source)
at oracle.forms.engine.Runform.onMessage(Unknown Source)
at oracle.forms.engine.Runform.processEventEnd(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.redispatchEvent(Unknown Source)
at oracle.ewt.lwAWT.LWComponent.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
..... [a list of libraries]
I've a windows XP and IE6. Do you know what can be wrong?
Thank you. -
dears,
i was design an form that read an excel sheet and upload the excel sheet contant into a table on DB, the excel sheet contain only 2 columns, the problem is when i compile the form CTRL+K there is no errors shown but when the form run i click Browes button but it give me error as below
ORA-06508 PL/SQL could not find program unit being called .
the program unit is client_get_file_name it a package within WEBUTIL attached library, the problem is the form cant call any package or anything from WEBUTIL attached library.
on the form i have 2 buttons
First Button Code: "Browes"
Declare
V_FILE VARCHAR2(2000);
BEGIN
V_FILE := client_get_file_name(NULL, NULL, NULL, NULL, open_file, TRUE);
:main_block.FNAME := V_FILE;
EXCEPTION
WHEN OTHERS THEN
my_alert('There Is Error: '||sqlerrm); -- My_alert(p_text) is program unit
RAISE FORM_TRIGGER_FAILURE;
END;
Second Button code : "Import to DB"
DECLARE
MYFILE CLIENT_TEXT_IO.FILE_TYPE;
filename varchar2(100);
temp varchar2(1000);
t1 varchar2(1000);
t2 varchar2(1000);
cust_id number;
dfrom date;
dto date;
ccode varchar2(100);
r varchar2(1000);
transfer_status boolean;
begin
filename := :main_block.fname;
MYFILE := CLIENT_TEXT_IO.FOPEN(filename, 'r');
SYNCHRONIZE;
SYNCHRONIZE;
CLIENT_TEXT_IO.get_line(MYFILE,temp);
t1:=temp;
while temp is not null loop
CLIENT_TEXT_IO.get_line(MYFILE,temp);
t1:=temp;
select substr(t1,1,instr(t1,',') -1)
into t2
from dual;
ccode:=t2;
select substr(t1,instr(t1,',') +1)
into t1
from dual;
insert into trc_upload -- table on DB
values(t2,t1);
commit;
end loop;
CLIENT_TEXT_IO.FCLOSE(MYFILE);
EXCEPTION
WHEN DDE.DDE_APP_FAILURE THEN
my_alert('WINDOWS APPLICATION CANNOT START.');
WHEN DDE.DDE_PARAM_ERR THEN
my_alert('A NULL VALUE WAS PASSED TO DDE');
WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN
my_alert('DDE CANNOT ESTABLISH A CONVERSATION');
WHEN DDE.DMLERR_NOTPROCESSED THEN
my_alert('A TRANSACTION FAILED');
end;
so please to help me on this issue
Note:
the form deployed under UNIX on Application Server
Thanks
Murad.From ORA-06508 is seems like WEBUTIL.pll is not found in the runtime-environment.
Possible solutions:
Check if the WEBUTIL.pll (or plx) is on the path where the fmx-File is placed.
If not, check the FORMS90_PATH in your env-File (normally default.env) (you didn't mention your forms-Version, may also be FORMS60_PATH) and if the WEBUTIL.pll is in that path, if not adjust the env-file.
If its still not working, check if WEBUTIL.pll is attached including the full Path (unattach WEBUTIL.pll and reattach it without the path)
Last hint: Case-sensitivity: If you attach in lowercase-letters and library is in uppercase on unix-system the library will not be found at runtime. You won't see how the the pll was attached, best method is to unattach library and reattach it in correct case.
Another remark:
The DDE-Exception seem to be useless, because you don't use DDE (and i would not work for its not available under unix).
Hope this helps -
Problem in writiing data to UTL_File
Hello Friends,
I'm using UTL_FILE to write the data into csv file, but in the table 1 description column is there which contains 3000 characters.
My problem is i'm not able to write more than 750 characters in csv file and if i tried to do so then get the FILE_WRITE_ERROR. error msg
I tried by breaking the column into 3 different strings by giving the column as diffrent-different aliases but facing the same problem.
Please help me to write all the characters i.e 3000 charcters in a file.
Is there any character length limitation in csv file?
Regards,
AnandAs others have stated MAX_LINESIZE parameter of FOPEN is what matters.
SQL> create table t(c1 varchar2(4000), c2 varchar2(4000))
2 /
Table created.
SQL> insert into t values(rpad('*',4000,'*'),rpad('#',4000,'#'))
2 /
1 row created.
SQL> commit
2 /
Commit complete.
SQL> select length(c1), length(c2) from t
2 /
LENGTH(C1) LENGTH(C2)
4000 4000
SQL> create or replace directory utl_dir as 'e:\oracle\log_files\utl_akivanew'
2 /
Directory created.
SQL> declare
2 lFile_Handle utl_file.file_type;
3 lc1 t.c1%type;
4 lc2 t.c2%type;
5 begin
6 select c1, c2 into lc1, lc2 from t;
7
8 lFile_Handle := utl_file.fopen('UTL_DIR','test.csv','W', 10000);
9
10 utl_file.put_line(lFile_handle, lc1||','||lc2);
11
12 utl_file.fclose(lFile_Handle);
13 end;
14 /
PL/SQL procedure successfully completed.
SQL> declare
2 lFile_Handle utl_file.file_type;
3 lc1 t.c1%type;
4 lc2 t.c2%type;
5 begin
6 select c1, c2 into lc1, lc2 from t;
7
8 lFile_Handle := utl_file.fopen('UTL_DIR','test.csv','W', 7000);
9
10 utl_file.put_line(lFile_handle, lc1||','||lc2);
11
12 utl_file.fclose(lFile_Handle);
13 end;
14 /
declare
ERROR at line 1:
ORA-29285: file write error
ORA-06512: at "SYS.UTL_FILE", line 69
ORA-06512: at "SYS.UTL_FILE", line 604
ORA-06512: at line 12 -
Forms9i-Webutil : problem with CLIENT_TEXT_IO
hello,
This is a small function to create a local file whith CLIENT_TEXT_IO
Forms 9i
JInitiator: Version 1.3.1.13
Utilisation de la version JRE 1.3.1.13-internal Java HotSpot(TM) Client VM
Répertoire d'accueil de l'utilisateur = C:\Documents and Settings\degrelle
Configuration du proxy : aucun proxy
JAR cache enabled
Location: C:\Documents and Settings\degrelle\Oracle Jar Cache
Maximum size: 50 MB
Compression level: 0
when the cursor is about ten lines, all is OK,
but when the cursor is about 100 lines, the Forms application become out of order !
in the java console, nothing is display after the WUF[getProperty()] Getting property WUF_TEXTIO_OPEN line
PROCEDURE export_texte IS
LF$File CLIENT_TEXT_IO.FILE_TYPE;
LC$Name Varchar2(100) ;
LC$Fic Varchar2(100) ;
Cursor EMISSIONS IS
Select
REGION,
DATE_HEURE_PRESSE,
TITRE,
CHAPEAU
From
EMISSIONS_REGIONS
Where
DATE_HEURE_PRESSE Between :CONTROL.DATE_DEB and :CONTROL.DATE_FIN
order by
region,
date_heure_presse
LC$Old_region EMISSIONS_REGIONS.REGION%Type := 'X' ;
BEGIN
LC$Name := To_char( :CONTROL.DATE_DEB, 'DAY' ) || ' HEBDO ' || Ltrim( :PARAMETER.HEB_NUMERO ) || '.txt' ;
LC$Fic := WEBUTIL_FILE.FILE_OPEN_DIALOG
'D:\',
LC$Name,
'Sélectionner un fichier'
If LC$Name is null Then
Return ;
End if ;
LF$File := CLIENT_TEXT_IO.FOPEN(LC$Fic, 'W');
CLIENT_TEXT_IO.PUT_LINE( LF$File, 'les magazines et documentaires de votre région' ) ;
CLIENT_TEXT_IO.PUT_LINE( LF$File, To_char( :CONTROL.DATE_DEB, 'FMDay DD Month' ) ) ;
CLIENT_TEXT_IO.PUT_LINE( LF$File, '' ) ;
For C_EMS in EMISSIONS Loop
If C_EMS.region <> LC$Old_region Then
CLIENT_TEXT_IO.PUT_LINE( LF$File, '' ) ;
CLIENT_TEXT_IO.PUT_LINE( LF$File, C_EMS.region ) ;
LC$Old_region := C_EMS.region ;
End if ;
CLIENT_TEXT_IO.PUT( LF$File, To_char( C_EMS.date_heure_presse, 'HH24"h"MI' ) ) ;
CLIENT_TEXT_IO.PUT( LF$File, ' ' ) ;
CLIENT_TEXT_IO.PUT_LINE( LF$File, C_EMS.titre ) ;
If C_EMS.chapeau is not null Then
CLIENT_TEXT_IO.PUT_LINE( LF$File, C_EMS.chapeau ) ;
end if ;
End loop ;
CLIENT_TEXT_IO.FCLOSE( LF$File ) ;
END;
2004-sept.-09 15:05:08.121 WUT[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.jacob.dll
2004-sept.-09 15:05:08.215 WUT[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
2004-sept.-09 15:05:08.231 WUT[loadSettings()] Local properties file loaded
2004-sept.-09 15:05:08.278 WUT[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.JNIsharedstubs.dll
2004-sept.-09 15:05:08.371 WUT[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
2004-sept.-09 15:05:08.418 WUT[setProperty()] Setting property WUC_GET_LOCAL_PROPERTY to syslib.d2kwut60.dll
2004-sept.-09 15:05:08.528 WUT[getProperty()] Getting property WUC_GET_LOCAL_PROPERTY
2004-sept.-09 15:05:13.543 WUF[setProperty()] Setting property WUF_GFN_DIRNAME to D:\
2004-sept.-09 15:05:13.637 WUF[setProperty()] Setting property WUF_FILENAME to SAMEDI HEBDO 37.txt
2004-sept.-09 15:05:13.637 WUF[setProperty()] Setting property WUF_FILTER to false
2004-sept.-09 15:05:13.746 WUF[setProperty()] Setting property WUF_GFN_MESSAGE to Sélectionner un fichier
2004-sept.-09 15:05:13.840 WUF[setProperty()] Setting property WUF_GFN_MULTISELECT to FALSE
2004-sept.-09 15:05:13.840 WUF[getProperty()] Getting property WUF_GFN_OPENFILE
2004-sept.-09 15:05:17.621 WUF[setProperty()] Setting property WUF_FILENAME to D:\SAMEDI HEBDO 37.txt
2004-sept.-09 15:05:17.621 WUF[setProperty()] Setting property WUF_TEXTIO_FILEMODE to W
2004-sept.-09 15:05:17.621 WUF[getProperty()] Getting property WUF_TEXTIO_OPEN
*** !!!-- the console stop display at this point when the function write more than 10 lines !!! ***
2004-sept.-09 15:05:20.278 WUF[setProperty()] Setting property WUF_TEXTIO_HANDLE to 1
2004-sept.-09 15:05:20.387 WUF[setProperty()] Setting property WUF_TEXTIO_PUT to 19/20 édition des régions et des locales
2004-sept.-09 15:05:20.481 WUF[setProperty()] Setting property WUF_TEXTIO_NEWLINE to 1
2004-sept.-09 15:05:20.575 WUF[setProperty()] Setting property WUF_TEXTIO_CLOSE to 1
2004-sept.-09 15:05:56.840 WUI[VBeanCommon.destroy()] WebUtil GetClientInfo Utility being removed..
2004-sept.-09 15:05:56.840 WUI[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:56.840 WUF[VBeanCommon.destroy()] WebUtil Client Side File Functions being removed..
2004-sept.-09 15:05:56.840 WUF[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:56.840 WUH[VBeanCommon.destroy()] WebUtil Client Side Host Commands being removed..
2004-sept.-09 15:05:56.840 WUH[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:56.840 WUS[VBeanCommon.destroy()] WebUtil Session Monitoring Facilities being removed..
2004-sept.-09 15:05:56.856 WUS[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:56.856 WUT[VBeanCommon.destroy()] WebUtil File Transfer Bean being removed..
2004-sept.-09 15:05:56.856 WUT[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:56.856 WUO[VBeanCommon.destroy()] WebUtil Client Side Ole Functions being removed..
2004-sept.-09 15:05:56.856 WUO[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:56.856 WUL[VBeanCommon.destroy()] WebUtil C API Functions being removed..
2004-sept.-09 15:05:56.856 WUL[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
2004-sept.-09 15:05:57.106 WUB[VBeanCommon.destroy()] WebUtil Browser Functions being removed..
2004-sept.-09 15:05:57.106 WUB[VBeanCommon.destroy()] 0 out of 0 object references removed, 0 (total) global references outstanding
*** this is OK when the cursor is about only ten lines ***
any idea ?CORRECTION :
the problem occurs after the FCLOSE() statment.
so in all cases, the file is created on the client machine and it is correct (but very slow; about 30 seconds to create a 1008 bytes file with 80 lines !).
it is just when the cursor is about 50 lines that the Forms application is space out.
it seems to be the Clean() statments that are not applyed. -
Having problem in recognising file using utl_file package..
Hi,
I am using utl_file utility to read the CSV file, utl_file.fopen function is useed to open file. This fopen function has three input parameters, second parameter is file name. My problem is that, i have to read file on daily basis. File name will be like:- DDMMYYYYHHMISS. Last six characters are for hour minute second of the file generation time. If the name has only DDMMYYYY then I can give the file name like TO_CHAR(SYADATE,'DDMMYYYY'), because on a particular date its same for the whole day. But hours, minutes and seconds will be of the time when the file is generated, it may be different for different days. In this condition how can I standardize the value for file name parameter in fopen function.
Thanks in advance.Bharat Kaushik wrote:
Actually.....
I am gettting file from some other place..... And those people are not agreed to send file without exact time.JAVA solution is here
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:7506780031005
Or if you want PL/SQL .. (May Be kiddy)
--Please Note: SYSDATE is 26th in our DB.
SQL> declare
2 fp utl_file.file_type;
3 dt date := trunc(sysdate);
4 begin
5 while (dt <= sysdate) loop
6 begin
7 fp := utl_file.fopen('OGL_REPORT_ACCESS','TEST'||to_char(dt,'ddmmyyyyhh24miss')||'.csv','r');
8 dbms_output.put_line('TEST'||to_char(dt,'ddmmyyyyhh24miss'));
9 utl_file.fclose(fp);
10 exit;
11 exception
12 when utl_file.INVALID_OPERATION then
13 null;
14 end;
15 dt := dt + 1/24/60/60;
16 end loop;
17 end;
18 /
TEST26042009010102
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.45
SQL> select sysdate from dual;
SYSDATE
26-APR-09 -
Problem with access rights by using UTL_FILE
Hi all,
Could you please help me with the following problem. A search on this forum did not result in the final solution:
- We are using an Oracle XE database on an Oracle VM instance
- I want to export a lot of data to the filesystem, by using UTL_FILE.
- The package that calls UTL_FILE, should be installed in the database schema 'XXCUST'.
- I have created a folder '/home/oracle/XX_EXPORT_FOLDER' on the filesystem
- I have created a database directory 'XX_EXPORT', which links to this folder
- I have granted read and write to public for this folder
- I use the following script to export the files:
DECLARE
l_file_handle UTL_FILE.FILE_TYPE;
BEGIN
l_file_handle := UTL_FILE.FOPEN( location => 'XX_EXPORT', filename => 'test.txt',open_mode => 'W', max_linesize => 100);
UTL_FILE.PUT_LINE(l_file_handle, 'TEST');
UTL_FILE.FCLOSE(l_file_handle);
END;
When I run this script with the user 'XXCUST' I get the following error:
ORA-06521: PL/SQL: Error mapping function
ORA-06512: at "SYSTEM.UTL_FILE", line 41
ORA-06512: at "SYSTEM.UTL_FILE", line 478
ORA-06512: at line 15
06521. 00000 - "PL/SQL: Error mapping function"
*Cause: An error was detected by PL/SQL trying to map the mentioned
function dynamically.
*Action: Check the stacked error (if any) for more details.
When I run this script with the user 'sys as sysdba', I don't get any errors. My testfile is created successfully.
What should I do to use this script with user XXCUST?What are the permissions on this folder:
/home/oracle/XX_EXPORT_FOLDER
Maybe you are looking for
-
Error 4280 again, but this is a poll. Share your experiences...
Hello out there... Okay so I've been researching this error 4280 when trying to burn on iTunes that (according to posters in this forum) signals "optical power calibration error." Trying many of the same brand discs (and another crappy brand), I've c
-
Question i backed up my iphone how do I open old texts and other info
Question I backed up my iphone on itunes. I see that it was backed up then restored it. How do I get the info i backed up?
-
Changing the cursor position in an input text field and Removing leading numeric zeros
Flash8 - AS2 It's good to be back after all these years and thanks for the faithfull folks like kglad, Ned Murphy, Rothrock and all the others who give so much of themselves to make this forum a success! My Problem: I have an input text field that is
-
Cannot uninstall itunes to download newest version
I kept getting an msi error when trying to update to the latest version of itunes. i was told to uninstall itunes and quicktime and download the newest version directly. i was able to uninstall quicktime, but i am getting the same msi error msg when
-
HT5129 how do i get it to quit popping up telling me it couldn't transfer the pics?
Moving Pics from mobile me to iphoto. I don't have any pics in mobile me to even transfer but it keeps popping up. How do I stop it?