惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
C
Cybersecurity and Infrastructure Security Agency CISA
Cisco Talos Blog
Cisco Talos Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Scott Helme
Scott Helme
Project Zero
Project Zero
E
Exploit-DB.com RSS Feed
S
Secure Thoughts
K
Kaspersky official blog
L
Lohrmann on Cybersecurity
NISL@THU
NISL@THU
WordPress大学
WordPress大学
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LINUX DO - 热门话题
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
A
About on SuperTechFans
Hacker News: Ask HN
Hacker News: Ask HN
AWS News Blog
AWS News Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hacker News: Front Page
F
Full Disclosure
Latest news
Latest news
Schneier on Security
Schneier on Security
The Hacker News
The Hacker News
T
Troy Hunt's Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Jina AI
Jina AI
Martin Fowler
Martin Fowler
P
Proofpoint News Feed
TaoSecurity Blog
TaoSecurity Blog
G
GRAHAM CLULEY
Forbes - Security
Forbes - Security
V
V2EX - 技术
酷 壳 – CoolShell
酷 壳 – CoolShell
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
MongoDB | Blog
MongoDB | Blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
P
Privacy International News Feed
C
Check Point Blog
N
News and Events Feed by Topic

博客园 - Bingo Lee

创业这三年¥.NET之尴尬处境 创业这三年@各种奇遇 创业这3年#迈出第一步 传统企业信息化 中国式IT的项目 谁来衡量我们的价值??? 加班?!希望“京东”不是你的最后一站 WinRAR自动备份文件 ASP.NET MVC3 入门指南之数据验证[源码RAR下载] Sql server 实用技巧之主键、系统表与代码生成器[源码+视频] 英孚订课助手 全自动备份vss和sql数据库(含源码下载) Asp.net MVC3.0 入门指南 7.1 展示查找页面 SQL SERVER VS ORCALE(实现已有数据行自增) Asp.net MVC3.0 入门指南 6 审视编辑方法和视图 ASP.NET MVC3.0 入门指南 5 从控制器访问模型数据 Asp.net MVC3.0 入门指南 4 模型 Model Asp.net MVC3.0 入门指南 3.2视图 View Asp.net MVC3.0 入门指南 3.1视图 View
Excel插入、更新Orcale
Bingo Lee · 2011-07-12 · via 博客园 - Bingo Lee

2011-07-12 11:00  Bingo Lee  阅读(1767)  评论()    收藏  举报

如何才能把Excel中的数据导入Orcale中呢?

本文提供一种间接的思路:

利用Sql Server和Excel的近亲关系,在Sql Server中利用OpenDataSource方法读取Excel,并把数据拼写成符合oracle的sql语句。

(sql server2005需要手工开启OpenDataSource功能,

sql server2005 -> 配置工具 -> 外围应用配置器 -> 功能的外围应用配置器 -> Database Engine -> 即席远程查询,

如下图所示)

配置sql server2005即席远程查询功能

在sql server中执行如下代码:

需要注意:

1)请提供正确的文件路径和Sheet名称;

2)关闭要读取的Excel文件,否则会报错;

3)确保to_date函数对应的字段在Excel中为日期类型;

SELECT  'update userinfo set Useducation = '''
        + CASE WHEN [现文化程度] IS NULL THEN '' 
				ELSE [现文化程度] END 
        + CASE WHEN [技术等级] IS NULL THEN '' 
				ELSE ''', Usskilllevel = ''' + [技术等级] END +  ''''
        + CASE WHEN [加入党派日期] IS NULL THEN '' 
				ELSE ', Usdangtuantime = to_date(''' + CONVERT(VARCHAR(12), [加入党派日期], 110)+ ''',''mm-dd-yyyy'')' END
		+ CASE WHEN [入路工作日期] IS NULL THEN '' 
				ELSE ', Usinputtime = to_date(''' + CONVERT(VARCHAR(12), [入路工作日期], 110)+ ''',''mm-dd-yyyy'')' END
		+ CASE WHEN [出生日期] IS NULL THEN '' 
				ELSE ', Usbirthdate = to_date(''' + CONVERT(VARCHAR(12), [出生日期], 110)+ ''',''mm-dd-yyyy'')' END				
        + ' where Uscardid =''' + [身份证号] + ''';'              
FROM    OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
                       'Data Source=D:\gongren.xls;Extended Properties=Excel 8.0')...[Sheet1$]

执行结果如下:

update userinfo set Useducation = '中等专科', Usinputtime = to_date('12-25-2000','mm-dd-yyyy'), Usbirthdate = to_date('09-06-1976','mm-dd-yyyy') where Uscardid ='132430197609061413';
update userinfo set Useducation = '大学', Usskilllevel = '中级工', Usdangtuantime = to_date('07-11-2000','mm-dd-yyyy'), Usinputtime = to_date('07-01-2003','mm-dd-yyyy'), Usbirthdate = to_date('08-21-1979','mm-dd-yyyy') where Uscardid ='132826197908210332';
update userinfo set Useducation = '大专', Usskilllevel = '高级工', Usdangtuantime = to_date('07-03-2001','mm-dd-yyyy'), Usinputtime = to_date('01-01-2005','mm-dd-yyyy'), Usbirthdate = to_date('10-26-1980','mm-dd-yyyy') where Uscardid ='132421198006260032';

在pl/sql中执行上述代码就行了。