SQL & PL/SQL :: Read International Characters Through Utl_file Function
Jul 19, 2010i am using oracle 10g enterprise edition.whether its possible to read international characters from the text file using the utl_file function..?
View 1 Repliesi am using oracle 10g enterprise edition.whether its possible to read international characters from the text file using the utl_file function..?
View 1 RepliesOracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
"CORE 11.1.0.6.0 Production"
i am trying to read the file, for which i m using the following:
l_utlfile_hdr := utl_file.fopen(p_dir,'header_evnt.txt', 'R');
utl_file.get_line(l_utlfile_hdr, l_hdr_evnt);
it gets these three characters at the start of the line
l_hdr_evnt = 
So i saved header_evnt.txt as UTF-8, and used utl_file.fopen_nchar, utl_file.get_line_nchar, which got rid of first two characters, but still has ¿. How to get rid of that?
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production
PL/SQL Release 11.1.0.6.0 - Production
"CORE 11.1.0.6.0 Production"
Is there a way to read Excel file using UTL_FILE package ?
Like our usual method:
l_utlfile := utl_file.fopen(p_dir, p_filename, 'R',2000);
p_filename is event.xls
Or do we need to convert that file to .csv or .txt ?
We have a requirement to create a file using UTL_FILE package. so we tried to generate the file in directory at UNIX level,for example "/tmp" which means when we executing the stored procedure which in turn calls UTL_FILE package and create a file say "a.txt". On checking the permission for "a.txt", it shows as follows
-rw-r----- oracle dba a.txt
this means read and write for oracle user, read for dba group and no permission for other user.
our requirement is to have the following privileges at UNIX level.
-rw-r--r-- oracle dba a.txt
Is it possible to do at oracle level since the file is owned by oracle user or at UNIX level (with out logging to oracle user)?
Environment: UNIX AIX 6.1 and Oracle 11.2.0.3
Need to write a function that should allow only characters and numbers in Login ID using pl sql.
View 7 Replies View Relatedthe below request.
My company has many products, whenever customer purchase any product purchase timestamp should be inserted into product_details table .
Note: timestamp of UK, Philippines, Singapore, India time should be inserted automatically as my company is world based company .
I have tried to convert the date format to other(uk,singpore,manalia) timings but i couldn't get proper reply.
SELECT to_char(sysdate,'DD-MON-YYYY HH:MI:SS AM') INDIA,
to_char(new_time(sysdate, 'EST', 'GMT'),'DD-MON-YYYY HH:MI:SS AM') D2 ,
to_char(new_time(sysdate, 'PST', 'GMT'),'DD-MON-YYYY HH:MI:SS AM') D3 ,
to_char(new_time(sysdate, 'EST', 'PST'),'DD-MON-YYYY HH:MI:SS AM') D4
FROM dual
I got the below output.
INDIA D2 D3 D4
----------------------- ----------------------- ----------------------- -----------------------
31-OCT-2011 06:06:16 PM 31-OCT-2011 11:06:16 PM 01-NOV-2011 02:06:16 AM 31-OCT-2011 03:06:16 PM
The HTML code for the bracket character '[' is & # 91; (without spaces). In my SQL, I would like to convert the word [you into & # 91;you. Is there a way to do that?
I know that replace() will work, but with that you have to supply a list of chars to replace; I
Need a code which prevents the User from entering more than 30 characters in a field. Although the variable can accept more than 30 characters. My requirement is to validate the field by restricting up to 30 characters.
View 6 Replies View RelatedI am on 11g.
I need to remove the alpha characters from a string, leaving only numbers, but I am getting unexpected results:
SQL> SELECT TRANSLATE('3N', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', NULL) a FROM DUAL;
A
-
I thought this would leave the 3 from the 3N, but it is returning an empty string. For my application, the string '3N' could be any length, will only contain letters and numbers, and the letters will always come at the end, but there could be more than one letter
VALID INPUT samples:
4
25
11F
361NG
8ABC
create table test
(
name varchar2(50),
descd varchar2(50)
)
insert into test values ('kethlin','da,dad!tyerx');
insert into test values ('tauwatson','#$dfegr');
insert into test values ('jennybrown','fsa!!trtw$ fda');
insert into test values ('tauwatson','#$dfegr ,try');
how do I get the first three characters and last three characters from name field and remove all the junk characters from descd field?
so my o/p be like;
Quote:('ketlin','dadadtyerx')
('tauson','dfegr')
('jenown','fsatrtw fda')
('tauson','dfegr try')
I Got a scnario like a upload file contains
1.Header(Contains the File Name,Branch Name,MIS date)
2.Body(Customer Details)
3.Footer (File Name,Contians Total Number of Records and Number of Customers)
Like
CustomerDet_11-12-2013.csv,Chennai,11-12-2013
101,AAA,Savings,'M',10000
102,BBB,Current,'O',2000
103,CCC,Deposit Acct,'F',3000
CustomerDet_11-12-2013.csv,3,15000
How to handle this scnario through UTL_File
I have an application that creates files using the utl_file package. It works fine but one of the lines in the file should hold the number of bytes in the file (on a line formatted like 'FileSize: 2104'). Unfortunately this line is not the last line of the file and the lines that follow it are variable in length.
My approach therefore is as follows:
1. Write the 'FileSize: ' line during file creation.
2. Write the remaining lines of data to the file (but don't close it).
3. Use utl_fgetattr to find the file size.
4. Go back and find the 'FileSize' line I need to update, using get_line to read it into the buffer.
5. Append the filesize (plus the number of characters that the variable I use to store the filesize value) to the buffer string.
6. Write the line back to the file using put_line.
However I keep getting invalid file operation errors however I try to re-access the file...
PROCEDURE setUtlFileSize (pFileName IN VARCHAR2,
pFileHandle IN utl_file.file_type) IS
vbFileExists BOOLEAN;
viFileLen NUMBER;
viFileBlockSize NUMBER;
vsFileRecord VARCHAR2(2000);
[code].......
This gives me the following output.... (for two files)... currently I am using some generic exception handling just to show me the error.
File Length: 2106
File Position: 0
-29283,ORA-29283: invalid file operation
File Length: 497
File Position: 0
-29283,ORA-29283: invalid file operation
Process exited.
Two things here concern me: The File Position suggests that the current offset position is set to the start of the file... but since I had not closed or performed any other operation since the last put_line and fflush (which are used to add lines to the file) I had expected that the offset position would be the same as the file length?
Secondly: Even if the position had been reset to the start of the file I don't understand why the get_line gives me the oracle error.
I am trying read a File to find out the error message through UTL_FILE.m. But the loop used inside is not getting closed.
CREATE OR REPLACE procedure alert_mail_A
as
v_flag varchar2(10);
mesg varchar2(100);
c1 utl_smtp.connection; -- passing the datatype to a variable.
c varchar2 (1000);
B utl_file.file_type;
[code]........
I'm using
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options
I'm creating a file using UTL_FILE.FOPEN and UTL_FILE.PUTF
But I don't know the file I created is in which encoding ASCII, UTF-8, EBCDIC etc.
1.) How can I create files in my desired encoding using UTL_FILE?
2.) Does UTL_FILE use database encoding? If yes then how to find out database encoding?
3.) Which encoding is used by UTL_FILE by default?
I have make utl_file. Its run in oracle 10 g. But when i run oracle 9i it give some error.
ERROR at line 1:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "SYS.UTL_FILE", line 120
ORA-06512: at "SYS.UTL_FILE", line 204
ORA-06512: at "HR.EXP_DATA", line 9
ORA-06512: at line 1.
[code]......
How to spool the Japanese characters in table using UTL_FILE. I tried with utl_file.fopen it's general,it's spooling. but i am not sure it this right way or not. in this case we need to change any character.
We can't see this characters in TOAD. Only possible in PLSQL developer
create table test1(name varchar2(1000),fname varchar2(1000))
insert into test1 values ('名を入力してください。','姓を入力してください。')
commit;
oracle 9i, I am reading about UTL_FILE package.make this in Hr Schema.Where hire date between date 1 and date 2.
View 8 Replies View Relatedwhen I am running a cursor and printing its data into an excel file using utl_file, the file size is nearly 50mb. But if I run the cursor and copy its data manually into an excel sheet the file size is only 22mb. I am unable to undersatnd why there is difference in file size.
View 6 Replies View RelatedWe have a p/slq procedure that reads a *.txt file using the UTL_FILE package. The contents of the file are then inserted into a database table.
At the end of the procedure we close the open file using UTL_FILE.FCLOSE.
There is a program (non-oracle)that attempts to move the file to a new location after being read into Oracle. The problem is that the application cannot move the file as the file is locked. ie message displays that the file is open and cannot be moved to a new location.
Is there anything else that we are missing besides the UTL_FILE.FCLOSE.
I'm trying to read the data from flat file and write data into multiple files based on the condition. The value of each line is checked with the Flag Table (Id NUMBER, FlagType VARCHAR(25), Flag CHAR(1)), If the Flag is True then new file has to be created and corresponding line has to be moved into new file otherwise it has to continue with the same file.
CREATE OR REPLACE PROCEDURE rw_demo (File_In VARCHAR2, File_out VARCHAR2) IS
InFile utl_file.file_type;
OutFile utl_file.file_type;
vNewLine VARCHAR2(4000);
i PLS_INTEGER;
j PLS_INTEGER := 0;
SeekFlag BOOLEAN := TRUE;
[code].........
I want to use UTL_FILE package to create OS file. How to resolve this error. Oracle11g under XP.
SQL> create directory my_dir as 'c: emp';
Directory created.
1 create or replace procedure test_1(md in varchar2)
2 is
3 file utl_file.file_type;
4 begin
5 file := utl_file.fopen(md,'abc.log','w');
6 utl_file.put_line(file,'EMPLOYE REPORT');
7 utl_file.fclose(file);
8* end;
SQL> /
Procedure created.
SQL> execute test_1('MY_DIR');
BEGIN test_1('MY_DIR'); END;
RROR at line 1:
RA-06510: PL/SQL: unhandled user-defined exception
RA-06512: at "SYS.UTL_FILE", line 98
RA-06512: at "SYS.UTL_FILE", line 157
RA-06512: at "SCOTT.TEST_1", line 5
RA-06512: at line 1
I want to extract data from a table and write into a txt file using UTL_FILE utility.I have written the below query. I am able to see query is returning data.But it is not creating file and writing data into it.
CREATE OR REPLACE DIRECTORY DOC_PATH AS '/apps/orarpt/SJDEV/utl'
CREATE OR REPLACE PROCEDURE xxcfi_outbound_test (errbuf OUT VARCHAR2,
retcode OUT VARCHAR2)
AS
CURSOR emp_cur
[code].....
I am using an Oracle 8i database.We intend creating a dbms_job that would run every 5 minutes. The job executes a script that would use utl_file to read two text files (a header file and detail file) from a particular directory and load the data into temporary tables. The naming convention of the files are Parts_Master_DD/MM/YY HH:MI:SS and Parts_Stats_DD/MM/YY HH:MI:SS. Both files to be stored in the same directory.
If the file name was constant ie. Parts_Master, Parts_Stats I would not have a problem. However with each file name now going to be unique, how do I handle this using utl_file. To add to my dilemma, within an hour more than one set of files could be piped to the directory to be read into the database.
I managed to upload images to a database server, resize them, copy to the application server and everything worked just fine - the Apex page successfully displayed images. Since last week, things have broken. This is how: there's a directory object which points to application server's directory:
SQL> select * from all_directories;
OWNER DIRECTORY_NAME DIRECTORY_PATH
------- ------------------------------ -----------------------------------
SYS SLIKE_4005_UPLOAD d:gisslike_4005_upload --> on a database server
SYS SLIKE_4005 \my-iasd$homegisslike_4005 --> on an application server
SQL>
I can use a directory located on a database server:
D:GISSlike_4005_upload>dir photo_resize.*
Volume in drive D is RAID
Volume Serial Number is 88F2-69D2
Directory of D:GISSlike_4005_upload
[code]....
How come it doesn't work? I was absent last week, database server was restarted for some reason (there were Windows' updates which required restarting). After that, all applications (lucky us, just two of them, but in multiple procedures/functions) return FALSE for UTL_FILE.FGETATTR.
We recreated directory objects, but that didn't work (UNC or not, no difference). I Googled quite a lot, read Metalink notes - nothing I did solved the problem.
what these OS updates were about; maybe they are not to be blamed at all. Both servers (database & application) run MS Windows Server 2003 Standard Edition Service Pack 2. In the meantime, a colleague developed a workaround (it uses UTL_HTTP) which works, but it is MUCH slower than the previous UTL_FILE.FGETATTR option.
Why don't we keep these images on the database server (instead of the application server)?I was told that Apache is incapable of accessing mapped network directories so we used what we could.
can we use features of utl_file in oracle forms.
View 2 Replies View RelatedIs anyway to create function based index for group function columns.
For example
select max(timestamp),min(age),averge(sal).... ... .. from tab;
I have the following C code:
class Factorial {
public:
int getVal (int a);
};
[code]....
/When I am trying to execute this function always get the ORA-06521. I changed the data types - but nothing changed.
Just in case, listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = db)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
[code]....
What is the Difference between a Stand Alone Function/Procedure & a Function/Procedure declared in a Package.
View 2 Replies View RelatedWhat is advantage of Deterministic function over normal function?
What is the diff B/W Deterministic function and normal function and also give me a example in which scenario we use Deterministic function?
We have a production database that have : NLS_LANGUAGE=FRENCH_FRANCE.WE8ISO8859P1.
We use (INSERT, UPDATE) arabic and french languages, and it works properly.
When I issue SQL statments to retrieve arabic data (with SQL*PLUS), it works and it returns correct arabic format.
When I use PHP, with the same small query, the arabic format is not correct.
I've tried changing the encoding characters on my browsers (IE and FF) and it's still incorrect.