是否有到 Oracle SQLPLUS 的 .Net 接口? [英] Is there a .Net interface to Oracle SQLPLUS?

查看:20
本文介绍了是否有到 Oracle SQLPLUS 的 .Net 接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一些自动化来控制 SQL 脚本的执行.这些脚本通过 SQL*PLUS 运行,并在其中包含 PL/SQL 调用(因此我无法通过 ODP.NET 运行它们).

I'm developing some automation to control the execution of SQL scripts. The scripts are run through SQL*PLUS and contain PL/SQL calls in them (hence I can't run them through ODP.NET).

我想知道是否有 .NET 接口到 SQL*PLUS?如果有,有人用过吗?

I was wondering if there was a .NET interface to SQL*PLUS? If so has anyone used it?

推荐答案

我花了一段时间才弄清楚如何让它全部工作,所以这是我的调查结果:

It took me a while to figure out how to make it all work so here is the result of my investigations:

c# 代码:

ORAUtils.execString(@"c:	mp.sql 'Oracle sucks!'");
...

using System.Diagnostics; -- where the Process stuff lives
...
public static int execString(string scriptFileName)
{
 ...
 ProcessStartInfo processInfo = new ProcessStartInfo();
 processInfo.FileName = "sqlplus.exe";
 processInfo.Arguments = "user/pwd@db @" + scriptFileName;
 ...
 Process process = Process.Start(processInfo); // typo in code above small p instead of caps helps
 ...

结果命令行:

sqlplus.exe user/pwd@db @c: mp.sql 'Oracle 很烂!'

sqlplus.exe user/pwd@db @c: mp.sql 'Oracle sucks!'

输入 sqlplus/?在 dos 提示中,您将获得语法:

Type sqlplus /? in a dos prompt and you'll get the syntax:

sqlplus

这里 logon=user/pwd@db 和 start=@c: mp.sql 'Oracle 糟透了!'

Here logon=user/pwd@db and start=@c: mp.sql 'Oracle sucks!'

它将启动sql文件并将参数字符串传递给它.

It will start the sql file and pass it the parameter string.

tmp.sql 第一行:

tmp.sql first line:

提示 &1

将显示参数字符串.

谢谢

这篇关于是否有到 Oracle SQLPLUS 的 .Net 接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆