我想执行以下操作
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;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在调用一个脚本,该脚本有多个语句以;;并且在文件末尾包含@符号.在db2命令行上,我可以使用db2 -td @ -f.我想知道如何将@符号定义为语句终止符,以便我可以从csharp执行脚本.这是示例sql文件:
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@
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1093 次 |
最近记录: |