我正在使用Array Binding将一系列Python脚本导入Oracle数据库:
using (OracleCommand cmd = conn.CreateCommand())
{
cmd.CommandText = @"insert into scripts (nscript, scriptname, scriptdescr, scripttext, created, modified, createdby)
values (nscript.nextval, :1, :2, :3, sysdate, sysdate, 'XXX')";
OracleParameter paramScriptName = new OracleParameter("ScriptName", OracleDbType.Varchar2, 64);
paramScriptName.Value = scriptNames.ToArray();
OracleParameter paramScriptDescription = new OracleParameter("ScriptDescripption", OracleDbType.Varchar2, 128);
paramScriptDescription.Value = scriptDescriptions.ToArray();
OracleParameter paramScriptText = new OracleParameter("ScriptText", OracleDbType.Long, 0);
paramScriptText.Value = scriptTexts.ToArray();
cmd.Parameters.Add(paramScriptName);
cmd.Parameters.Add(paramScriptDescription);
cmd.Parameters.Add(paramScriptText);
cmd.ArrayBindCount = scriptNames.Count;
cmd.ExecuteNonQuery();
paramScriptName.Dispose();
paramScriptDescription.Dispose();
paramScriptText.Dispose();
}
遵循本指南:http://www.oracle.com/technetwork/issue-archive/2009/09-sep/o59odpnet-085168.html
但是,我注意到一些较长的脚本在导入时会被截断。
有关我做错的任何建议吗?
非常感谢。
史蒂夫