- 浏览: 236195 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
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 1405Usually we need to check the ta ... -
PL/SQL Studing Notes
2011-10-20 21:48 1326As an extension of native ... -
一组Linux命令
2011-09-29 13:09 1426今天做测试发现Oracle服务器磁盘使用率达到100%导致Or ... -
Thinking in JDBC
2011-09-22 20:56 1817This blog will beas on a series ... -
Oracle Reference Exception Gallery
2011-07-05 22:28 1587The Following Exception is real ... -
SQL Studying Note I - Join
2011-07-02 10:28 1183SQL Join SQL Join are u ... -
Windows批处理脚步实例-创建Oracle数据库用户并向该用户添加数据
2010-12-11 09:25 3396Windows批处理使用方便、 ... -
Oracle starting up 5: Oracle 10g在WINDOWS服务中有5个Oracle服务项及解决与服务项相关的几个问题
2010-10-10 17:25 2292在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 4262在家装了台服务器,因为家里电脑不行,所以服务器和客 ... -
Oracle Start Up 3:Oracle数据库基础
2010-10-05 20:17 21281. 创建TableSpace、用户及给用户分派权限 ... -
Oracle Start Up 2 Oracle 框架构件、启动、解决一个问题
2010-10-02 14:07 34663Warming Up: 本文 ... -
Oracle Start Up 1: 几个概念和Oracle数据库的物理结构和逻辑结构
2010-09-29 23:31 1983Oracle 基本概念 数据库(Database) ... -
Oracle 连接错误;ORA-27101: shared memory realm does not exist
2010-09-28 14:27 26274XP下安装Oracle10g 昨天下午刚安装完可以连接(Sq ... -
SQL Server 2005 dev 学习(1)
2010-09-26 15:14 1938关键字:SqlServer2005Dev版本安装 SQL Se ... -
Cassandra Dev 3:Cassandra 应用之CassandraAppender
2010-08-13 13:59 2034本文的目的是展示 ... -
Cassandra Dev 2: Cassandra入门(续) - Cassandra Cluster
2010-08-09 13:56 57235. Cassandra CLI 一般数据库服务器都会提供一 ... -
Cassandra Dev 1: Cassandra 入门
2010-08-06 17:55 4563最近, Cassandra 绝对是一个比较前端的话题 ...
相关推荐
这是一个基于Objective-C语言的基础案例集。旨在用于给初学者快速了解Objective-C语言的语法。.zip
01 整理数据 _ 合并多数据,分析更有趣.ipynb
创业、工作、毕业、课程需要人群,可以参考使用,支持有偿远程部署,联系我,保证一定能跑起来
流程行业智能工厂总体设计方案qy.pptx
ModStartBlog现代化个人博客系统 v5.2.0源码.rarModStartBlog现代化个人博客系统 v5.2.0源码.rar
企业IT统一智能运营管理解决方案qy.pptx
华为用“三阶段十二步”法保证业务战略引领数字化转型32个精华问答glkb.pptx
搭建数据分析和机器学习平台,实现如下功能:设计一个网页版的用户界面,支持从本地选取数据集、自动可视化分析、查看训练记录、查看训练模型参数和绘图和支持完成机器学习任务。核心工具:streamlit和pycaret,部署和运行方便,只需streamlit run main.py命令即可。
毕业设计 jsp+基于JB的人事管理系统(源代码+论文)
基于C++14语法的任务链.zip
毕业设计JSP+SQL网站流量统计管理系统(源代码+论文)
本Bash脚本用于自动化管理Java JAR应用的启动、停止及监控。首先检查JAR进程是否在运行,如在运行则安全终止。随后,使用预设的Java参数启动JAR文件,并将输出和错误日志重定向至日志文件。启动后,脚本持续监控JAR进程状态,确保其在预设时间内成功启动。本脚本提供了灵活的配置和错误处理机制,为Java应用的运维管理带来了便捷与可靠性。
2024-2030全球及中国阵列光谱仪行业研究及十五五规划分析报告
基于Reactor模式,支持单线程、多线程Reactor,也支持UDP服务
一、源码特点 java web进销存管理系统是一套完善的java web信息管理系统,对理解JSP java编程开发语言有帮助,系统具有完整的源代码和数据库,系统主要采用B/S模式开发。开发环境为 TOMCAT7.0,Myeclipse8.5开发,数据库为sqlserver2008,使用java语言开发。 二、功能介绍 如博客中介绍 三、注意事项 1、管理员账号:admin密码:admin 数据库配置文件DBO.java 2、开发环境为TOMCAT7.0,Myeclipse8.5开发,数据库为sqlserver2008,使用java语言开发。 3、数据库文件名是jspjxc.mdf,系统名称jxc 4、系统首页地址:http://127.0.0.1:8080/jxc/login.jsp 不包含人工调试服务,如果需要联系作者购买
如何在 Ubuntu 16.04 上使用 Node-RED 连接你的物联网设备
libAvogadro1-1.98.1-2.1.armv7hl
毕业设计:vue+springboot学校田径运动会管理系统的设计(源码 + 数据库 + 说明文档) 二、系统规划 2 (一)业务流程分析 2 1.业务流程 2 (二)系统功能需求 3 1.学生功能需求 3 2.管理员功能需求 4 3.工作人员(老师)功能需求 4 (三)可行性分析 4 1.经济可行性 4 2.技术可行性 5 4.法律可行性 5 三、系统分析 6 (一)系统的逻辑模型 6 1.数据流程图设计 6 2.数据字典 6 四、系统设计 8 (一)系统功能模块划分和功能模块图 9 (二)系统开发技术和开发工具 10 1.开发技术 10 2.开发工具 11 (三)数据库设计 11 1.概念结构设计 11 2.逻辑结构设计 12 3.数据表设计 13 (四)系统界面设计 13 (五)处理流程设计 14 1.用户功能处理流程设计 14 2.管理员功能处理流程设计 15
湖南化工职院技术学院紫薇大道绿化服务项目招标资料.zip
FLIR T4xx 系列用户手册