Reading Csv Files with Text_io in Oracle D2k Forms
2016-12-25 20:07
1131 查看
Below is the example to read and import comma delimited csv file in oracle forms with D2k_Delimited_String package. This package is available in D2kdlstr.pll library.
To download D2kdlstr.Pll Click Here
Create the following procedure in program unit of Oracle forms.
Procedure Import_csv_file (I_FILENAME IN VARCHAR2) Is
-- Text File Type
Infile Text_Io.File_Type;
Linebuf Varchar2 (4000);
V_Getstring Varchar2 (100);
-- Field Values Array
Type Fieldvalue Is Table Of Varchar2(100)
Index By Binary_Integer;
Fv Fieldvalue;
Rec_Count Number := 0;
Begin
Infile := Text_Io.Fopen (I_FILENAME, 'R');
-- Read File
Loop
---
Rec_Count := Rec_Count + 1;
Text_Io.Get_Line (Infile, Linebuf);
Linebuf := Linebuf || ',';
-- read from 1 to number of occurrences of comma or any other delimiter
-- below giving example for 3 occurrences
For I In 1 .. 3
Loop
Fv (I) := D2k_Delimited_String.Getstring (Linebuf, I, False, ',');
End Loop;
Begin
---
Insert Into yourtable (col1, col2, col3)
Values ( Fv(1), Fv(2), Fv(3));
Exception
When Others
Then
Message (Sqlerrm);
End;
End Loop;
Text_Io.Fclose (Infile);
Exception
When No_Data_Found Then
-- End Of The Text File Reached.... Then Save...
commit_form;
-- Message(Sqlerrm);
Text_Io.Fclose (Infile);
Message ('Import Completed.');
When Others Then
Text_Io.Fclose (Infile);
message(sqlerrm);
End;
See also:
[align=left]
Reading CSV Files in Oracle Forms
Reviewed by Marian Burn on
Feb 25
Rating:
5[/align]
To download D2kdlstr.Pll Click Here
Create the following procedure in program unit of Oracle forms.
Procedure Import_csv_file (I_FILENAME IN VARCHAR2) Is
-- Text File Type
Infile Text_Io.File_Type;
Linebuf Varchar2 (4000);
V_Getstring Varchar2 (100);
-- Field Values Array
Type Fieldvalue Is Table Of Varchar2(100)
Index By Binary_Integer;
Fv Fieldvalue;
Rec_Count Number := 0;
Begin
Infile := Text_Io.Fopen (I_FILENAME, 'R');
-- Read File
Loop
---
Rec_Count := Rec_Count + 1;
Text_Io.Get_Line (Infile, Linebuf);
Linebuf := Linebuf || ',';
-- read from 1 to number of occurrences of comma or any other delimiter
-- below giving example for 3 occurrences
For I In 1 .. 3
Loop
Fv (I) := D2k_Delimited_String.Getstring (Linebuf, I, False, ',');
End Loop;
Begin
---
Insert Into yourtable (col1, col2, col3)
Values ( Fv(1), Fv(2), Fv(3));
Exception
When Others
Then
Message (Sqlerrm);
End;
End Loop;
Text_Io.Fclose (Infile);
Exception
When No_Data_Found Then
-- End Of The Text File Reached.... Then Save...
commit_form;
-- Message(Sqlerrm);
Text_Io.Fclose (Infile);
Message ('Import Completed.');
When Others Then
Text_Io.Fclose (Infile);
message(sqlerrm);
End;
See also:
http://www.foxinfotech.in/2014/02/writing-text-file-from-tabular-block-oracle-forms.html
[align=left]
Reading CSV Files in Oracle Forms
Reviewed by Marian Burn on
Feb 25
Rating:
5[/align]
相关文章推荐
- Using Text_IO To Read Files in Oracle D2k
- Reading and Writing CSV Files in C#
- 论文阅读:Reading Text in the Wild with Convolutional Neural Networks
- Reading files in MySQL with file_priv = no
- Reading and Writing CSV Files in MFC
- Writing Text Files On The Client in Oracle Forms 10g
- Working with CSV files in Bash
- Reading and Writing CSV Files in C#
- Reading and Writing CSV Files in MFC
- 论文阅读:Reading Text in the Wild with Convolutional Neural Networks
- START WITH and CONNECT BY in Oracle
- Reading and writing text files
- Using #region Directive With JavaScript Files in Visual Studio 【转载】
- Working with Files in C#
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- START WITH and CONNECT BY in Oracle SQL
- Working with Configuration Files (app.config) in C++/CLI
- Optimistic Locking with Concurrency in Oracle
- Oracle OMF--------Tablespace creation is a snap with Oracle Managed Files
- PowerTip of the Day-Replace Text in Files