Reading Csv Files with Text_io in Oracle D2k Forms

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:

http://www.foxinfotech.in/2014/02/writing-text-file-from-tabular-block-oracle-forms.html

Reading CSV Files in Oracle Forms

Reviewed by Marian Burn on

Feb 25

Rating: 
5

时间: 2024-12-18 13:20:00

Reading Csv Files with Text_io in Oracle D2k Forms的相关文章

Using GET_APPLICATION_PROPERTY in Oracle D2k Forms

Using GET_APPLICATION_PROPERTY in Oracle D2k Forms DescriptionReturns information about the current Form Builder application. You must call the built-in once for eachvalue you want to retrieve.Usage NotesTo request a complete login, including an appe

DISPLAY_ITEM built-in in Oracle D2k Forms

DISPLAY_ITEM built-in in Oracle D2k Forms DescriptionMaintained for backward compatibility only. For new applications, you should use theSET_ITEM_INSTANCE_PROPERTY built-in. DISPLAY_ITEM modifies an item's appearance byassigning a specified display a

Using Text_IO To Read Files in Oracle D2k

Suppose you want to read a file from D2k client and want to store its content in Oracle database. But if you will insert row by row from client to server it will take more time and increase lot of network traffic / round trips. The solution of this p

Upload Files To FTP in Oracle Forms D2k

Upload Files To FTP in Oracle Forms D2k Use following procedure to upload files to Ftp. PROCEDURE Ftp_Upload IS    outfile text_io.file_type;BEGIN    -- write a ftp script    outfile := text_io.fopen('D:\ftpsendsource.ftp', 'w');    text_io.put_line(

Using Call_Form in Oracle D2k

Using Call_Form in Oracle D2k CALL_FORM examples/* Example 1:** Call a form in query-only mode.*/BEGINCALL_FORM('empbrowser', no_hide, no_replace, query_only);END;/* Example 2:** Call a form, pass a parameter list (if it exists)*/DECLAREpl_id PARAMLI

Obtaining Query Count Without executing a Query in Oracle D2k

Obtaining Query Count Without executing a Query in Oracle D2k Obtaining a count of records that will be retrieved by EXECUTE_QUERY before actually performing it in a database block is especially useful when the requirement is to prevent navigation to

Pre-Query trigger in Oracle D2k / Oracle Forms

Pre-Query trigger in Oracle D2k / Oracle Forms DescriptionFires during Execute Query or Count Query processing, just before Form Builder constructs and issuesthe SELECT statement to identify rows that match the query criteria.Definition Level form or

Reading/Writing files with MSSQL‘s OPENROWSET

nfortunately, Microsoft SQL Server's SQL dialect Transact-SQL does not support reading and writing files in an easy way as opposed to MySQL's LOAD_FILE() function and INTO OUTFILEclause. Of course, with xp_cmdshell being enabled, you can read and wri

将.csv格式的文件导入oracle数据库中

第一种方法 1.选择工具---文本导入器 2.选择 到oracle的数据选择所有者和表. 3.选择打开文件,选择要导入的文本 4.在field中配置表的对应关系,filed1对应的是.csv中的第一列,配置对应数据的那一列,注意类型,不然导入数据会报错.之后点导入,完成. 第二种方法 1.创建控制文件 如,在E:\创建 test.ctl文件,文件内容为 load data ---控制文件标志 infile'e:/asd.csv'---要输入的文件名及路径 into tablejyzxsj_rdl