Is there a .Net interface to Oracle SQLPLUS?

前端 未结 2 1336
野的像风
野的像风 2021-01-12 08:47

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 t

2条回答
  •  既然无缘
    2021-01-12 09:12

    You can do it in C# with this piece of code:

    public int execString(string scriptFileName)
    {
       int exitCode;
       ProcessStartInfo processInfo;
       Process process;
       int timeout = 5000;
    
       processInfo = new ProcessStartInfo("sqlplus.exe", "@" + scriptFileName);
       processInfo.CreateNoWindow = true;
       processInfo.UseShellExecute = false;
       process = process.Start(ProcessInfo);
       process.WaitForExit(timeout);
       exitCode = process.ExitCode;
       process.Close();
    
       return exitCode;
    }
    

    In VB.NET you could accomplish the exact same thing, using the same API in the framework, but I don't know much about VB.NET syntax.

    You could also try inspecting SQL/Plus DLLs and see if you can get something out of them. But I think that even though it should be a faster (performance wise) approach, it will be way more complicated than using what I am suggesting.

提交回复
热议问题