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 problem is to store the content of the text file into an array and then pass it to database procedure and insert record through that procedure. Here is the example step by step:
1) Create a package in Oracle database.
as
Type textrow is table of Varchar2(1000)
index by binary_integer;
Procedure Insert_into_table (iarray in textrow);
End;
/
Create or Replace Package Body DB_insert
as
Procedure Insert_into_table(iarray in textrow)
is
Begin
For i in 1..iarray.count loop
Insert into Dummytbl values (iarray(i));
-- you can extract the content from iarray(i) to insert values into multiple fields
-- e.g. iarray(i).fieldname
--
End Loop;
Commit;
End;
/
2) Now in D2k write a procedure to read text file and store it into array and pass it to that package you crated above.
is
infile Text_IO.File_type;
irow DB_insert.textrow;
nelm number := 1;
Begin
infile := text_io.fopen(ifilename, 'r');
Loop
text_io.get_line(infile, irow(nelm));
nelm := nelm + 1;
End Loop;
Exception
when no_data_found then
-- end of file reached
text_io.fclose(infile);
message('Read Completed.');
-- pass it to database
DB_insert.insert_into_table(irow);
message('Data saved.');
when others then
if text_io.is_open(infile) then
text_io.fclose(infile);
end if;
message(sqlerrm);
End;
See also: Reading csv files with Text_io
http://foxinfotech.blogspot.com/2013/02/reading-and-importing-comma-delimited.html
Using Text_IO To Read Files in Oracle D2k的更多相关文章
- 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_ ...
- 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 ...
- Using Call_Form in Oracle D2k
Using Call_Form in Oracle D2k CALL_FORM examples/* Example 1:** Call a form in query-only mode.*/BEG ...
- Using GET_APPLICATION_PROPERTY in Oracle D2k Forms
Using GET_APPLICATION_PROPERTY in Oracle D2k Forms DescriptionReturns information about the current ...
- DISPLAY_ITEM built-in in Oracle D2k Forms
DISPLAY_ITEM built-in in Oracle D2k Forms DescriptionMaintained for backward compatibility only. For ...
- Pre-Query trigger in Oracle D2k / Oracle Forms
Pre-Query trigger in Oracle D2k / Oracle Forms DescriptionFires during Execute Query or Count Query ...
- Creating List Item in Oracle D2k
Special Tips for List Items in Oracle D2k In this section, I shall discuss some special tips and tec ...
- Creating Object Library OLB in Oracle D2k Form
With following steps you can create Object Library (OLB) in Oracle D2k Forms.Step - 1Create a form i ...
- Creating Timer in Oracle D2k / Forms 6i and Displaying a Clock
Creating Timer in Oracle D2k / Forms 6i and Displaying a Clock This is about timer in D2k An externa ...
随机推荐
- Linux下/etc/resolv.conf 会被重新写入
主要原因是因为安装了network manager,所以在启动后每次都会重写这个文件. 所以需要在network manager->eth0->ipv4->Automatic(DHC ...
- 典型的检查对float精度理解的代码
-rand()%); vy = ); vz = ); pList_particle[i].m_velocity = Vector3(vx,vy,vz); ... 1,3行代码的vx和vz的值域可以通过 ...
- 《高质量C++/C编程指南》陷阱 【转】
作者:幻の上帝 出处:http://hi.baidu.com/frankhb1989/item/185f0a14823dd1f8dceeca2c 此文硬伤不少,且相对谭XX的书而言隐晦许多,不建议新手 ...
- jboss-as 目录结构(转)
jboss-as 目录结构(Directory Structure) Directory Description bin Contains startup, shutdown and other sy ...
- SQL server 创建 修改表格 及表格基本增删改查 及 高级查询 及 (数学、字符串、日期时间)函数[转]
SQL server 创建 修改表格 及表格基本增删改查 及 高级查询 及 (数学.字符串.日期时间)函数 --创建表格 create table aa ( UserName varchar(50 ...
- Android的适配器
//====================ArrayAdapter=================================== public class List1 extends Ac ...
- 查找(顺序表&有序表)
[1]查找概论 查找表是由同一类型是数据元素(或记录)构成的集合. 关键字是数据元素中某个数据项的值,又称为键值. 若此关键字可以唯一标识一个记录,则称此关键字为主关键字. 查找就是根据给定的某个值, ...
- linux设备驱动归纳总结(九):1.platform总线的设备和驱动【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-111745.html linux设备驱动归纳总结(九):1.platform总线的设备和驱动 xxxx ...
- 给MD5加上salt随机盐值加密算法实现密码安全的php实现
给MD5加上salt随机盐值加密算法实现密码安全的php实现 如果直接对密码进行散列,那么黑客可以对通过获得这个密码散列值,然后通过查散列值字典(例如MD5密码破解网站),得到某用户的密码.加上sal ...
- 电影TS、TC、SCR、R5、BD、HD等版本是什么意思
在很多电影下载网站的影片标题中我们都能看到,比如<刺杀希特勒BD版>.<游龙戏凤TS版>等,这些英文缩写都是什么意思呢?都代表什么画质?以下就是各个版本的具体含义: 1.CAM ...