I am trying to do the following
public void ExecuteNonQuery(string script) { try { int returnCode; var builder = new DB2ConnectionStringBuilder { UserID = Context.Parameters["USERID"], Password =Context.Parameters["PASSWORD"], Database = Context.Parameters["DATABASE"], CurrentSchema = Context.Parameters["CURRENTSCHEMA"] }; using (var connection = new DB2Connection(builder.ConnectionString)) { using (var command = new DB2Command(script, connection) ) { command.CommandType = CommandType.Text; connection.Open(); returnCode = command.ExecuteNonQuery(); File.WriteAllText(Context.Parameters["LOGFILE"], "Return Code -1 Successful : " + returnCode); } } } catch (Exception ex) { Trace.WriteLine(ex.StackTrace); throw ex; } }
I invoke a script that has several statements ending in; and at the end of the file it contains the @ symbol. On the db2 command line, I could use db2 -td @ -f. I would like to know how to define the @ character as the operator terminator so that I can execute the script from csharp. Here is an example sql file:
DROP PROCEDURE fred@ CREATE PROCEDURE fred ( IN name, IN id ) specific fred language sql b1: begin update thetable set thename = name where table_id = id; end: b1 @ grant execute on procedure inst.fred to user dbuser@
source share