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 ...
随机推荐
- 「ruby」使用rmagick处理图像
安装rmagick gem A new release 2.13.2 of RMagick is now available on github as well as rubygems. This r ...
- html里那些细节
target="_top",项目是frameset形式写的,用这个在跳转的时候从父框架跳转
- Selenium 新手入门(C#)1. 用vs运行调用Selenium打开页面
Start步骤: 1.从http://docs.seleniumhq.org/download/ 下载 C# dll 文件和 Internet Explorer Driver Server(32 或 ...
- ILOG的一个基本应用——解决运输问题、转运问题
一.Ilog软件 该软件用来解决优化问题,大部分是线性问题,深一点的其他内容还不清楚.只知道一些基础的应用,网上相关内容很少.接下来就解决一个简单的运输问题 二.运输问题 数学模型 ILOG OPL程 ...
- python随机数的使用记录
一.random模块简介 Python标准库中的random函数,可以生成随机浮点数.整数.字符串,甚至帮助你随机选择列表序列中的一个元素,打乱一组数据等. 二.random模块重要函数 1 ).ra ...
- selenium webdriver三种等待方法
webdriver三种等待方法 1.使用WebDriverWait from selenium import webdriverfrom selenium.webdriver.common.by im ...
- FormData对象
FF4中增加了一个很有意思的对象,FormData.通常我们提交(使用submit button)时,会把form中的所有表格元素的name与value组成一个queryString,提交到后台.这用 ...
- diff 文件比较
测试数据: [xiluhua@vm-xiluhua][~]$ cat msn.txt aaa bbb bbb ccc ccc ddd bbb eee aaa ccc bbb sss [xiluhua@ ...
- Nagios监控Oralce
一.本文说明: 本文是监控本地的Oracle,其实监控远端的Oracle也是跟下面的步骤差不多的. 二.安装Nagios.Nagios插件.NRPE软件: 安装步骤可以参考<Linux下Nagi ...
- linux下echo命令详解(转)
linux的echo命令, 在shell编程中极为常用, 在终端下打印变量value的时候也是常常用到的, 因此有必要了解下echo的用法 echo命令的功能是在显示器上显示一段文字,一般起到一个 ...