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 them (hence I can't run them through ODP.NET).
I was wondering if there was a .NET interface to SQL*PLUS? If so has anyone used it?
You can do it in C# with this piece of code:
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.
It took me a while to figure out how to make it all work so here is the result of my investigations:
c# code:
Resulting command line:
sqlplus.exe user/pwd@db @c:\tmp.sql 'Oracle sucks!'
Type sqlplus /? in a dos prompt and you'll get the syntax:
sqlplus
Here logon=user/pwd@db and start=@c:\tmp.sql 'Oracle sucks!'
It will start the sql file and pass it the parameter string.
tmp.sql first line:
prompt &1
will display the parameter string.
Thx