如何使用 Powershell 将共享点列表插入 Oracle DB
我想从共享点列表中检索一些列表项,然后将其加载到 Oracle 表中。使用 powershell 是否可行? 任何想法或想法将不胜感激。 谢谢 ** 在插入 Oracle 之前在 powershell 中准备表的最佳方法是什么?
I would like to retrieve some list items from a sharepoint list and then load it into an Oracle table.Is this feasible using powershell.
Any thoughts or ideas would be appreciated.
Thanks
** What would be the best way to prepare the table in powershell before inserting into Oracle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经使用 SharePoint 和 SQL Server 完成了此操作。首先,您需要查询 SharePoint 列表,如我的博客文章中所述:
http://sev17.com/2009/02/using-oledb-with-sharepoint-lists/
其次,您需要插入到表中。在 SQL Server 中,我将使用 SQLBulkCopy 类,Oracle 也有类似的类,但它可能同样容易从 SharePoint 返回的 DataTable 生成和执行插入语句。这件作品需要做一些工作。查看 $dt 变量并生成插入语句。例如
$dt | foreach {"INSERT myOracleTable VALUES ('$($.Field1)','$($.Field2)');"}
您可以生成一个文件并使用 SQLPLus 来执行该文件:
$dt | foreach {"INSERT myOracleTable VALUES ('$($.Field1)','$($.Field2)');"} >>> ./out.sql
或者,我有一个由两部分组成的系列,用于从 Powershell 查询 Oracle:
http:// /sev17.com/tag/oracle/
编辑添加的示例:
I've done this with SharePoint and SQL Server. There's two parts first you'll want to query a SharePoint list as documented in my blog post:
http://sev17.com/2009/02/using-oledb-with-sharepoint-lists/
Second you'll want insert into a table. In SQL Server I would use the SQLBulkCopy class, there's a similar class for Oracle, but its probably just as easy to generate and execute insert statements from the DataTable returned from SharePoint. This piece will require a bit of work. Take a look at $dt variable and generate insert statemens. As an example
$dt | foreach {"INSERT myOracleTable VALUES ('$($.Field1)','$($.Field2)');"}
You could generate a file and use SQLPLus to execute the file:
$dt | foreach {"INSERT myOracleTable VALUES ('$($.Field1)','$($.Field2)');"} >> ./out.sql
Or, I've got a two-part series for querying Oracle from Powershell here:
http://sev17.com/tag/oracle/
Edit addded example:
您还可以使用 Sharepoint Web 服务来检索信息,我已经对此进行了一些描述 在这里。我在从 Powershell 访问数据库方面没有太多经验,但发现了一篇不错的博客文章 这里应该符合要求。
You could also use Sharepoint web services to retrieve the information, I've described it somewhat here. I don't have much experience in accessing databases from Powershell, but found a nice blog post here that should fit the bill.