程序中用oraclecommand的executeNonQuery()执行,可以看到的是返回的执行结果的条数,但是执行结果却不对。
而同样的Sql在PL/SQL dev中执行却能得到正确的结果,不知道为什么??请达人指点一下思路。delete from LIMCK_SECDEAL;insert into LIMCK_SECDEAL (
select t.deal_no, s.name, t.ccy,e.amount, e.comments, md.buy_sell,t.deal_dt, t.mature_dt, t.entity, t.cparty, d.ext_name dealer
from deals t, sectype s, events e, cparty c, mmdeals md, dealer d
where t.sectype = s.thekey and t.deal_no = e.deal_no and t.cparty = c.thekey and t.deal_no = md.deal_no and t.dealer = d.thekey and
s.name not like 'DEPODE%' and s.name not like 'LOANLO%' and t.trans_type = 'SE' and
t.deal_dt>= sysdate -6 and t.deal_dt<= sysdate and
c.name not like 'Z-%' and c.name <> 'DUMMY COUNTERPARTY' and
e.comments in('BOND SETTLEMENT','DISCOUNT AMOUNT') and t.in_use = 'Y'
);commit;
而同样的Sql在PL/SQL dev中执行却能得到正确的结果,不知道为什么??请达人指点一下思路。delete from LIMCK_SECDEAL;insert into LIMCK_SECDEAL (
select t.deal_no, s.name, t.ccy,e.amount, e.comments, md.buy_sell,t.deal_dt, t.mature_dt, t.entity, t.cparty, d.ext_name dealer
from deals t, sectype s, events e, cparty c, mmdeals md, dealer d
where t.sectype = s.thekey and t.deal_no = e.deal_no and t.cparty = c.thekey and t.deal_no = md.deal_no and t.dealer = d.thekey and
s.name not like 'DEPODE%' and s.name not like 'LOANLO%' and t.trans_type = 'SE' and
t.deal_dt>= sysdate -6 and t.deal_dt<= sysdate and
c.name not like 'Z-%' and c.name <> 'DUMMY COUNTERPARTY' and
e.comments in('BOND SETTLEMENT','DISCOUNT AMOUNT') and t.in_use = 'Y'
);commit;
可能是不是你程序中写SQL语句的时候分割没注意好
另外有个问题希望大家注意一下,我在程序中也不是一直有问题,只是每天早上启动的时候总是会有几次有问题
代码如下:
public bool ExecuteNonQueryTrans(string connString, CommandType cmdType, string [] cmdText)
{
using(OracleConnection conn=new OracleConnection(connString))
{
if (conn.State != ConnectionState.Open)
conn.Open();
OracleTransaction trans=conn.BeginTransaction();
OracleCommand cmd=conn.CreateCommand();
cmd.Transaction=trans;
int i=0;
try
{
for(i=0;i<cmdText.Length;i++)
{
if(cmdText[i].ToUpper().IndexOf("COMMIT")!=-1)
{
trans.Commit();
System.Threading.Thread.Sleep(300);
trans=conn.BeginTransaction();
cmd.Transaction=trans;
}
else
{
if(cmdText[i]!=""&&cmdText[i]!=" ")
{
cmd.CommandText = cmdText[i];
int j=cmd.ExecuteNonQuery();
this.frm.txtInfo.Text+="\r\n"+j.ToString();
}
}
}
trans.Commit();
}
catch(Exception ex)
{
trans.Rollback();
return false;
}
finally
{
conn.Close();
}
return true;
} }
delete没起作用?在程序中执行的时候.把commit去了试试
而且,即便不成功也不应该几千条重复的纪录,应该也就重复一遍,几百条而已;
“几千条重复纪录”是只有几条纪录,重复了上千次