Browse Source

Oracle ExecuteReturnBigIdentity BUG

pull/12/MERGE
sunkaixuan 7 years ago
parent
commit
2d3a1374c8
  1. 19
      Src/Asp.Net/SqlSugar/Realization/Oracle/Insertable/OracleInsertable.cs

19
Src/Asp.Net/SqlSugar/Realization/Oracle/Insertable/OracleInsertable.cs

@ -27,21 +27,32 @@ namespace SqlSugar
string sql = InsertBuilder.ToSqlString();
RestoreMapping();
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 : GetSeqValue(GetSeqName());
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 : GetSeqValue(GetSeqName()).ObjToInt();
return result;
}
public override long ExecuteReturnBigIdentity()
{
InsertBuilder.IsReturnIdentity = true;
PreToSql();
string sql = InsertBuilder.ToSqlString();
RestoreMapping();
var count = Ado.ExecuteCommand(sql, InsertBuilder.Parameters == null ? null : InsertBuilder.Parameters.ToArray());
var result = (this.GetIdentityKeys().IsNullOrEmpty() || count == 0) ? 0 :Convert.ToInt64(GetSeqValue(GetSeqName()));
return result;
}
public override int ExecuteCommand()
{
base.ExecuteCommand();
return base.InsertObjs.Count();
}
private int GetSeqValue(string seqName)
private object GetSeqValue(string seqName)
{
return Ado.GetInt(" SELECT " + seqName + ".currval FROM DUAL");
return Ado.GetScalar(" SELECT " + seqName + ".currval FROM DUAL");
}
protected override void PreToSql()
{
var identities = GetSeqNames();

Loading…
Cancel
Save