无法使用cmd.exe

时间:2017-11-06 12:43:44

标签: c# asp.net sql-loader

我试图通过在cmd.exe中调用它来在C#代码(调度程序)中执行 sqlldr 命令。我正在ORACLE 10g数据库的一个表中执行 INSERT 记录的命令。但是我从命令执行中得到的输出是不完整的,它给出如下,

SQL*Loader: Release 11.2.0.2.0 - Production on Mon Nov 6 16:23:22 2017
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

下面提到的编码,我已经完成了执行SQL loader命令。

string strCommand = "sqlldr userid=Username/Password@DBNAME, control=xyz.ctl, log=pqr.log";

            objProcStartInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe", "/c " + strCommand);
            //objProcStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            objProcStartInfo.RedirectStandardOutput = true;
            objProcStartInfo.UseShellExecute = false;
            // Do not create the black window.
            objProcStartInfo.CreateNoWindow = false;

            objProcStartInfo.RedirectStandardError = true;

            objProcess = new System.Diagnostics.Process();
            objProcess.StartInfo = objProcStartInfo;

            if (!objProcess.Start())
            {
                ErrorLog.LogError("Scheduler Info.", "Due to some technical reason the process of SQL loader could not started.");
            }
            else
            {
                // Get the output into a string
                string strResult = objProcess.StandardOutput.ReadToEnd();
                // Display the command output.
                Console.WriteLine(strResult);

                if (!string.IsNullOrEmpty(strResult))
                    ErrorLog.LogError("Scheduler Info.", "Output of SQL loader command :- " + strResult);
            }

如果有人这样做,请提供建议/解决方案。

1 个答案:

答案 0 :(得分:0)

我发现了主要问题。当我用提到的列交叉检查数据库的表列时。 Ctl文件,我发现列序列不匹配。在执行 sqlldr 命令时更正了列序列。它执行得很快。