since apparently my other idea how to send multiple Statements to the Oracle DB was not so easy I have to do it differently...
I want to use SQLPlus over Process to issue all possible Oracle SQL Commands. I now have the problem that the Statements are never added to the Shell. Ie.: When this Code is run it will open the Shell and say "connected to: Oracle ...." and then show the "SQL>" prompt.
The result will be: "SP2-0042 Unknown command "test", which is okay. However when it wants to run the SQL query it only writes into the Shell "SQL> 2" and nothing happens. The DB is not changed either. If I add another Query it will write "3" into the same Line.
ProcessStartInfo processInfo = new ProcessStartInfo();
processInfo.FileName = "sqlplus.exe";
processInfo.Arguments = "user/password@db";
processInfo.CreateNoWindow = false;
processInfo.UseShellExecute = false;
processInfo.WorkingDirectory = Path.GetTempPath();
processInfo.RedirectStandardInput = true;
processInfo.RedirectStandardOutput = false;
processInfo.RedirectStandardError = false;
// Process process = Process.Start(processInfo);
Process process = new Process();
process.StartInfo = processInfo;
//process.OutputDataReceived += (sender,args) => { System.Diagnostics.Debug.WriteLine("ohh i got something"); };
//process.ErrorDataReceived += (sender, args) => { System.Diagnostics.Debug.WriteLine("ohh i got some error"); };
process.Start();
process.StandardInput.WriteLine(" test");
Thread.Sleep(5000);
process.StandardInput.WriteLine("create or replace view test(ID) as select ID from USER");
Thread.Sleep(2000);
process.StandardInput.Flush();
// process.WaitForExit();
process.Close();
I don´t see what is missing, I am doing everything like in all those Examples online. Btw, can I somehow get if an Command has already been executed or will I have to parse the DataReceived Event?