- 浏览: 240038 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
akka_li:
学习了!但是为什么后续的没有了?!
EJB4:RMI和RMI-IIOP -
springaop_springmvc:
apache lucene开源框架demo使用实例教程源代码下 ...
Lucene学习笔记(一)Lucene入门实例 -
qepipnu:
求solr 客户端 jar包
Solr学习笔记(三)Solr客户端开发实例 -
zhangbc:
是这问题,赞!
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题 -
feilian09:
查询 select hibernate jdbc 那个效率快
Hibernate,JDBC性能探讨
I met a request: I need to read files from Computer File System and insert this readed files into Oracle database as Clob, and need to complete this through PL/SQL only.
To describ this request more clearly, we list the create table sql statements firstly:
create table stylesheet ( stylesheet_name varchar2(100) primary key not null, stylesheet_text CLOB );
Obviously, this is a very simple table, which has 2 column, stylesheet_name is table primary key has not null constraints, and stylesheet_text is a clob type use to store the files readed from Computer file system.
First: I found use Oracle External Tables skill can meet this request, But have some defects:
In this condition, we use Oracle Databse System Package DBMS_LOB, DBMS_LOB has some methods can handle this. DBMS_LOB.loadfromfile() can insert the clob values to database. So we need to read the file system's data to clob pattern, use BFILE can accomplish this, the whole processing SQL CODE as following:
CREATE OR REPLACE DIRECTORY XSLT_LOB_DIR AS 'C:/Share/xslt' / DECLARE dest_clob CLOB; src_bfile BFILE := BFILENAME('XSLT_LOB_DIR', 'MSProject2Plan.xslt'); BEGIN insert into stylesheet(stylesheet_name, stylesheet_text) values('MSProject2Plan', empty_clob()) returning stylesheet_text into dest_clob; DBMS_LOB.fileopen(src_bfile); DBMS_LOB.loadfromfile(dest_clob, src_bfile, DBMS_LOB.getlength(src_bfile)); DBMS_LOB.fileclose(src_bfile); commit; END; /
'MSProject2Plan.xslt' is the file we need to insert into table stylesheet, which saved under 'C:/Share/xslt' folder.
Use the above can sovle the Request only if this files and Oracle Database Syatem in the same machine, if you try this in Oracle client or other client the following error you will found :
ORA-22288: file or LOB operation FILEOPEN failed The system cannot find the path specified.
So this solution isn't able to meet our request, we need to find another solution:
Second: Use Oracle utility to load the file from Computer File System
SQL*Loader (sqlldr ) is the utility to use for high performance data loads. The data can be loaded from any text file and inserted into the database. The key feature what sqlldr can meet our request is : It Can Load data across a network. This means that you can run the SQL*Loader client on a different system from the one that is running the SQL*Loader server.
1. SQL*Loader architecture
The below figure depicts the SQL*Loader architecture. SQL*Loader reads a data file and a description of the data which is defined in the control file. Using this information and any additional specified parameters (either on the command line or in the PARFILE), SQL*Loader loads the data into the database.
2. The Test Sequence(a demo use SQL*Loader load data)
Also as the below figure depicted, My Test Example use a windows scrpits invoke test.sql, test.sql invoke the stylesheetcontrol.sql to complete the load processing.
3. Test Demo List:
run.cmd
@echo off set SYSTEMUSER=system set SYSTEMPASSWD=ADMIN set DBPROTOCOL=TCP set DBMODE=DEDICATED set COMUSR=IPCUSERTEST set COMPASSWD=tibco set DBSERVER=192.168.68.116 set DBPORT=1521 set SERVICENAME=orcl set COMDIR=c:/ set TABLESPACENAME=IPCTEST set SYSTEMCONNECTSTRING=%SYSTEMUSER%/%SYSTEMPASSWD%@(DESCRIPTION=(ADDRESS=(PROTOCOL=%DBPROTOCOL%)(HOST=%DBSERVER%)(PORT=%DBPORT%))(CONNECT_DATA=(SERVER=%DBMODE%)(SERVICE_NAME=%SERVICENAME%))) set IPCUSERCONNECTSTRING=%COMUSR%/%COMPASSWD%@(DESCRIPTION=(ADDRESS=(PROTOCOL=%DBPROTOCOL%)(HOST=%DBSERVER%)(PORT=%DBPORT%))(CONNECT_DATA=(SERVER=%DBMODE%)(SERVICE_NAME=%SERVICENAME%))) set SQLLDRCONNECTSTRING=%COMUSR%/%COMPASSWD%@//%DBSERVER%:%DBPORT%/%SERVICENAME% rem echo %SYSTEMCONNECTSTRING% rem echo %SQLLDRCONNECTSTRING% echo sql*loader load data start... echo. set RUN_SCRIPT=%ORACLE_HOME%/bin/sqlplus -l -s "%SYSTEMCONNECTSTRING%" @test.sql %SQLLDRCONNECTSTRING% %IPCUSERCONNECTSTRING% %RUN_SCRIPT%
test.sql
define SQLLDRCONNECTSTRING='&1' connect &IPCUSERCONNECTSTRING @stylesheetcontrol.sql &SQLLDRCONNECTSTRING
stylesheetcontrol.sql
define SQLLDRCONNECTSTRING='&1' set serveroutput on DECLARE BEGIN DBMS_OUTPUT.PUT_LINE('Create stylesheet table, Insert the MSProject2Plan.xslt into the stylesheet'); END; / create table stylesheet ( stylesheet_name varchar2(100) primary key not null, stylesheet_text CLOB ); host sqlldr &SQLLDRCONNECTSTRING control=loadXSLT.ctl log=logs/loadXSLT.log
loadXSLT.ctl
LOAD DATA INFILE xsltlist.dat INTO TABLE stylesheet REPLACE FIELDS TERMINATED BY ',' ( stylesheet_name CHAR(100), clob_filename FILLER CHAR(100), stylesheet_text LOBFILE(clob_filename) TERMINATED BY EOF )
xsltlist.dat
MSProject2Plan,../xslt/MSProject2Plan.xslt
Run the run.cmd the file under xslt folder(MSProject2Plan.xslt) will be loaded and insert into the table stylesheet.
发表评论
-
Oracle - Add Exist Validation Before Create Table
2011-11-07 13:49 1453Usually we need to check the ta ... -
PL/SQL Studing Notes
2011-10-20 21:48 1384As an extension of native ... -
一组Linux命令
2011-09-29 13:09 1474今天做测试发现Oracle服务器磁盘使用率达到100%导致Or ... -
Thinking in JDBC
2011-09-22 20:56 1875This blog will beas on a series ... -
Oracle Reference Exception Gallery
2011-07-05 22:28 1638The Following Exception is real ... -
SQL Studying Note I - Join
2011-07-02 10:28 1239SQL Join SQL Join are u ... -
Windows批处理脚步实例-创建Oracle数据库用户并向该用户添加数据
2010-12-11 09:25 3446Windows批处理使用方便、 ... -
Oracle starting up 5: Oracle 10g在WINDOWS服务中有5个Oracle服务项及解决与服务项相关的几个问题
2010-10-10 17:25 2342在Windows下安装Oracle 10g,安装完后在WIND ... -
Oracle starting up 5: Oracle数据库基础(续)
2010-10-07 14:15 0通用函数; 通用函数用于任何类型数据(包括空值) ... -
Oracle starting up 4: Oracle 10g 客户端 enterprise manager console 消失问题
2010-10-06 15:20 4319在家装了台服务器,因为家里电脑不行,所以服务器和客 ... -
Oracle Start Up 3:Oracle数据库基础
2010-10-05 20:17 22091. 创建TableSpace、用户及给用户分派权限 ... -
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题
2010-10-02 14:07 34862Warming Up: 本文 ... -
Oracle Start Up 1: 几个概念和Oracle数据库的物理结构和逻辑结构
2010-09-29 23:31 2050Oracle 基本概念 数据库(Database) ... -
Oracle 连接错误;ORA-27101: shared memory realm does not exist
2010-09-28 14:27 26358XP下安装Oracle10g 昨天下午刚安装完可以连接(Sq ... -
SQL Server 2005 dev 学习(1)
2010-09-26 15:14 1985关键字:SqlServer2005Dev版本安装 SQL Se ... -
Cassandra Dev 3:Cassandra 应用之CassandraAppender
2010-08-13 13:59 2095本文的目的是展示 ... -
Cassandra Dev 2: Cassandra入门(续) - Cassandra Cluster
2010-08-09 13:56 57945. Cassandra CLI 一般数据库服务器都会提供一 ... -
Cassandra Dev 1: Cassandra 入门
2010-08-06 17:55 4613最近, Cassandra 绝对是一个比较前端的话题 ...
相关推荐
The Cloud DBA-Oracle: Managing Oracle Database in the Cloud By Abhinivesh Jain, Niraj Mahajan English | PDF| 2017 | 228 Pages | ISBN : 1484226348 Learn how to define strategies for cloud adoption of...
The exam is targeted at experienced IT professionals who install, configure, deploy, and manage SharePoint 2016 installations in a datacenter and in the cloud. Candidates typically have more than four...
Thoroughly updated for Oracle Database 11g Release 2, this edition reveals new PL/SQL features and provides extensive code samples, ranging from simple examples to complex and complete applications, ...
Red_Hat_Enterprise_Linux-6-Managing_Confined_Services-en-US
Oracle Solaris 11.2 Managing Network Datalinks in Oracle Solaris 11.2-124
在本篇《Informix 教程 - 管理 Informix 日志》中,我们将深入探讨 Informix 数据库日志的配置与维护,这些日志对于确保数据库的可靠性至关重要。日志管理是数据库运维中的核心环节,特别是对于 Informix 这样的高...
【Informix 磁盘管理教程】:在数据库系统中,磁盘I/O性能是决定整体性能的关键因素,尤其对于Informix服务器来说。本教程由IBM Informix Champions成员Lester Knutsen主讲,深入探讨如何有效地管理和配置Informix...
Oracle Solaris 11.1 Managing Oracle Solaris11.1 Network Performance-200
Oracle Solaris 11.3 Managing ZFS File Systems-290
Oracle Solaris 11.3 Managing Network File Systems-186
该文档“Managing Auditing in Oracle Solaris 11.2-158”详细阐述了在Oracle Solaris 11.2环境中如何有效地管理和配置审计系统,旨在帮助管理员监控和记录系统的活动,以便于合规性检查、安全分析和问题排查。...
Oracle Solaris 11.1 Managing User Accounts and User Environments in Oracle Solaris11.1-70
Microsoft Teams 管理与配置 Microsoft Teams 是 Microsoft 365 中的一个关键组件,它提供了一个集成的通信和协作平台,旨在提高团队成员之间的协作和沟通效率。然而,为了确保 Teams 的安全和高效运作,管理员需要...
《Oracle 9i在Linux上的管理》是一本详细介绍如何在Linux操作系统上管理和维护Oracle 9i数据库系统的专业书籍。...《Managing Oracle9i on Linux.pdf》这本书将深入讲解这些内容,为读者提供详尽的指导。
Oracle Solaris 11.2 Managing Serial Networks Using UUCP and PPP in Oracle Solaris 11.2-220
Oracle WebDB Creating and Managing Components - Field-Level Help Oracle WebDB 是 Oracle 公司开发的一款基于 Web 的数据库管理系统,旨在帮助用户快速创建和管理数据库应用程序。下面是关于 Oracle WebDB ...
Oracle Solaris 11.2 Managing SMB File Sharing and Windows Interoperability in Oracle Solaris 11.2-136
本项目"Implementing-a-Database-for-Managing-Access-Control-main"旨在提供一个数据库解决方案,用于高效且安全地管理访问控制。 一、数据库设计 创建一个有效的数据库来管理访问控制,首先要考虑数据模型的设计...
在Oracle Solaris 11.3中,设备管理是一项至关重要的任务,它涉及操作系统如何识别、配置和控制硬件资源。Oracle Solaris 11.3提供了一套全面的工具和技术来有效地管理各种设备,包括网络接口、存储设备、输入输出...