2017-11-06 10 views
0

cmd.exe에서 호출하여 sqlldr 명령을 C# 코드 (스케줄러)에서 실행하려고합니다. 레코드를 ORACLE 10g 데이터베이스 테이블 중 하나에 기록합니다. 하지만 명령 실행에서 점점 오전 출력은C#에서 cmd.exe를 사용하여 sqlldr 명령을 완료 할 수 없습니다.

언급 코딩 아래
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 로더 명령을 실행하기 위해 수행 한 불완전하며 다음과 같이 주어진다.

string strCommand = "sqlldr userid=Username/[email protected], 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); 
      } 

아무도이 작업을 수행하지 않은 경우 친절하게 제안/해결책을 제공하십시오.

+0

은 로컬 폴더에 sqlldr입니까? 창을 보여주고 오류가 무엇인지 확인해보십시오. 오류가 아닌 출력 만 캡처합니다 – BugFinder

+0

이 명령을 직접 실행하면 작동합니까? 로그 파일에 어떤 내용이 있습니까? –

+0

UseShellExecute와 CreateNoWindow가 모두 true 일 경우 어떻게됩니까? – tofutim

답변

0

주요 문제점을 발견했습니다. 교차 할 때 언급 된 열이있는 데이터베이스의 테이블 열을 확인했습니다. Ctl 파일에서 열 순서가 일치하지 않습니다. sqlldr 명령을 실행할 때 열 순서가 수정되었습니다. 그것은 신속히 실행되었습니다.

+0

및 잘 작동하는 배치 파일의 sqlloader 구문? 그것은 어떤 점에서 다른가? –

+0

@ Nick.McDermaid : 예 .. SQL 로더 구문이 제대로 작동했습니다. – Rahul