S
sp00nyG
I have a few SQL scripts that need to be executed on an Oracle DB server.
They each contain multiple SQL statements that contain ALTER TABLEs, CREATE
TABLEs, and stored procedures that need to be compiled. There are no
SELECT-type commands; all the scripts alter the database schema in some way.
Using sqlplus.exe the scripts run with no problem. However, these scripts
are executed as part of a product deployment (from an MSI). In order to
remove the dependency on sqlplus on the target machine (which potentially
could be missing) I am using C# (3.5) to connect to the DB directly via
OleDb.
Basically I will read in the entire contents of the SQL script as a string
and then pass it to OleDbCommand.ExecuteNonQuery(). The problem is that the
ExecuteNonQuery() method does not know how to handle multiple SQL statements.
This means that any semicolon ( or slash (/) statement separators cause
the entire transaction to fail with an "invalid character" exception.
I am able to execute a single-statement query on the DB without any
problems, so everything is wired up properly.
I cannot modify the SQL scripts that are being executed-- they are provided
to me from a separate development group and are expected to say intact,
meaning, the way they appear in source control is how they should appear on
the target machine. My only involvement in the process is to execute the
scripts when the product is installed.
I cannot seem to find a definitive answer on how this could be accomplished
with either System.Data.OleDb or the System.Data.OracleClient, or even
Oracle.DataAccess.Client. Surely there must be a way to emulate the
functionality of sqlplus.exe in code?
Thanks for any help in advance!
They each contain multiple SQL statements that contain ALTER TABLEs, CREATE
TABLEs, and stored procedures that need to be compiled. There are no
SELECT-type commands; all the scripts alter the database schema in some way.
Using sqlplus.exe the scripts run with no problem. However, these scripts
are executed as part of a product deployment (from an MSI). In order to
remove the dependency on sqlplus on the target machine (which potentially
could be missing) I am using C# (3.5) to connect to the DB directly via
OleDb.
Basically I will read in the entire contents of the SQL script as a string
and then pass it to OleDbCommand.ExecuteNonQuery(). The problem is that the
ExecuteNonQuery() method does not know how to handle multiple SQL statements.
This means that any semicolon ( or slash (/) statement separators cause
the entire transaction to fail with an "invalid character" exception.
I am able to execute a single-statement query on the DB without any
problems, so everything is wired up properly.
I cannot modify the SQL scripts that are being executed-- they are provided
to me from a separate development group and are expected to say intact,
meaning, the way they appear in source control is how they should appear on
the target machine. My only involvement in the process is to execute the
scripts when the product is installed.
I cannot seem to find a definitive answer on how this could be accomplished
with either System.Data.OleDb or the System.Data.OracleClient, or even
Oracle.DataAccess.Client. Surely there must be a way to emulate the
functionality of sqlplus.exe in code?
Thanks for any help in advance!