使用进程在客户端服务器上执行 utl_recomp
Using a process to execute utl_recomp on client server
我想做的是创建一个打开 sqlplus、连接到远程服务器并执行数据库重新编译的进程。
string arg =
"\"conn " + myConnect + " as sysdba \""+
"\"begin UTL_RECOMP.RECOMP_SERIAL('" + mySchema + "'); end;\"";
Process pro = new Process()
pro.StartInfo.FileName = "sqlplus.exe";
pro.StartInfo.Arguments = arg;
pro.StartInfo.EnvironmentVariables["ORACLE_HOME"] = Srvr.OH;
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.RedirectStandardError = false;
pro.Start();
pro.WaitForExit();
进程运行但我的对象仍然无效。我已经远程连接并且 运行 这个 sql 语句从命令行作为 sysdba 成功。有任何想法吗?
string mySqlPath = path + ".sql";
string mysql = "begin UTL_RECOMP.RECOMP_SERIAL('" + mySchema + "'); end;";
string arg =
" /c echo / | " + pathway +"sqlplus.exe"
" -silent " + myConnect + " as sysdba" +
"@" + mysql;
StreamWriter strWr = new StreamWriter(mySqlPath);
strWr.WriteLine(mysql);
strWr.WriteLine("/");
strWr.Close();
Process pro = new Process()
pro.StartInfo.FileName = "cmd";
pro.StartInfo.Arguments = arg;
pro.StartInfo.EnvironmentVariables["ORACLE_HOME"] = Srvr.OH;
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.RedirectStandardError = false;
pro.Start();
pro.WaitForExit();
这非常适合远程重新编译!花了很长时间才弄清楚,但如您所见,必须添加更多代码。文件名中的 "cmd" 要求我关闭数据库、装载数据库、更改数据库存档日志、更改数据库闪回、更改数据库打开,然后退出。重新编译成功完成,我的验证过程也成功完成,返回时为 'INVALID' 选择了 0 行。
我想做的是创建一个打开 sqlplus、连接到远程服务器并执行数据库重新编译的进程。
string arg =
"\"conn " + myConnect + " as sysdba \""+
"\"begin UTL_RECOMP.RECOMP_SERIAL('" + mySchema + "'); end;\"";
Process pro = new Process()
pro.StartInfo.FileName = "sqlplus.exe";
pro.StartInfo.Arguments = arg;
pro.StartInfo.EnvironmentVariables["ORACLE_HOME"] = Srvr.OH;
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.RedirectStandardError = false;
pro.Start();
pro.WaitForExit();
进程运行但我的对象仍然无效。我已经远程连接并且 运行 这个 sql 语句从命令行作为 sysdba 成功。有任何想法吗?
string mySqlPath = path + ".sql";
string mysql = "begin UTL_RECOMP.RECOMP_SERIAL('" + mySchema + "'); end;";
string arg =
" /c echo / | " + pathway +"sqlplus.exe"
" -silent " + myConnect + " as sysdba" +
"@" + mysql;
StreamWriter strWr = new StreamWriter(mySqlPath);
strWr.WriteLine(mysql);
strWr.WriteLine("/");
strWr.Close();
Process pro = new Process()
pro.StartInfo.FileName = "cmd";
pro.StartInfo.Arguments = arg;
pro.StartInfo.EnvironmentVariables["ORACLE_HOME"] = Srvr.OH;
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.RedirectStandardError = false;
pro.Start();
pro.WaitForExit();
这非常适合远程重新编译!花了很长时间才弄清楚,但如您所见,必须添加更多代码。文件名中的 "cmd" 要求我关闭数据库、装载数据库、更改数据库存档日志、更改数据库闪回、更改数据库打开,然后退出。重新编译成功完成,我的验证过程也成功完成,返回时为 'INVALID' 选择了 0 行。