string connectionString = "User Id=SYSUSER;Password=11111;Data Source=//1111:1521/ORCL;";
nuget包:Oracle.ManagedDataAccess framework4.5 建议用Oracle19版本
private void execute()
{
using (OracleConnection connection = new OracleConnection(connectionString))
{
connection.Open();
string str = this.textBox1.Text.Replace("\n", "").Replace("\r", "");
string[] arrays = str.Split(';');
string sql = "begin\n";
foreach (var array in arrays)
{
if (string.IsNullOrEmpty(array))
{
continue;
}
sql += " " + array + ";\n";
}
sql += "end;";
using (OracleCommand command = new OracleCommand(sql, connection))
{
// 设置命令类型为批处理
command.CommandType = CommandType.Text;
command.ExecuteNonQuery();
}
}
}