while(...)
{
strSQL1 = "insert into sms_log_f(SMS_LOG_F_ID, SENDER, RECEIVER, SENDCONTENT, SYS_DATE, FAILURE_CODE) ";
strSQL1 += " values(sms_seq.nextval, '"+strSrc+"','"+strDes+"','"+strMsg+"', to_date('"+strDate+"', 'YYYYMMDDHH24MISS'), '"+strFlag+"'); "; if (pADOQuery-> SQL-> Count < 10)
{
pADOQuery-> SQL-> Append(strSQL1);
}
else
{ try
{
pADOQuery-> ExecSQL();
pADOQuery-> SQL-> Clear();
}
catch(Exception &e)
{
strMsg = pADOQuery-> SQL-> Text + " ¦";
Synchronize(ShowMessage); strMsg = e.Message;
Synchronize(ShowMessage);
iRet = -1;
}
}
...
} 上述为实际的代码,提交ORACLE数据库执行的时候,报 “ORA-00911: 无效字符”错误,但是我把打印出来的10条SQL语句拷贝到SQL PLUS中却运行正常。有没有人遇到过这个问题?
忘记怎么查看ORACLE的错误日志了,不知道能否看到详细信息。
有遇到这种问题的大侠请给予帮助,高分相送。
{
strSQL1 = "insert into sms_log_f(SMS_LOG_F_ID, SENDER, RECEIVER, SENDCONTENT, SYS_DATE, FAILURE_CODE) ";
strSQL1 += " values(sms_seq.nextval, '"+strSrc+"','"+strDes+"','"+strMsg+"', to_date('"+strDate+"', 'YYYYMMDDHH24MISS'), '"+strFlag+"'); "; if (pADOQuery-> SQL-> Count < 10)
{
pADOQuery-> SQL-> Append(strSQL1);
}
else
{ try
{
pADOQuery-> ExecSQL();
pADOQuery-> SQL-> Clear();
}
catch(Exception &e)
{
strMsg = pADOQuery-> SQL-> Text + " ¦";
Synchronize(ShowMessage); strMsg = e.Message;
Synchronize(ShowMessage);
iRet = -1;
}
}
...
} 上述为实际的代码,提交ORACLE数据库执行的时候,报 “ORA-00911: 无效字符”错误,但是我把打印出来的10条SQL语句拷贝到SQL PLUS中却运行正常。有没有人遇到过这个问题?
忘记怎么查看ORACLE的错误日志了,不知道能否看到详细信息。
有遇到这种问题的大侠请给予帮助,高分相送。
应该用那个方法的。
而且,如果你插入的数据有特殊字符,如:单引号,就会跟Sql中的单引号冲突,导致出现问题。
关键字符已经过滤掉了,这点早就想到了。还有,这个代码是C++Builder的,不是Java
var
I:Integer;
imax:Integer;
commit_count:Integer;
date1,date2:TDateTime;
vstr:string;
begin
imax:=10000;
//imax:=4;
commit_count:=0;
ADOQuery1.Close;
ADOQuery1.SQL.Text:= 'insert into test(sid,sname,sdate) values(:sid,:sname,getdate()) ';
ADOQuery1.Prepared:=True;
ProgressBar1.Min:=0;
ProgressBar1.Max:=imax;
for I:=1 to imax do
begin
try
if not ADOConnection1.InTransaction then ADOConnection1.BeginTrans;
ADOQuery1.Active:=False;
ADOQuery1.Parameters.ParamByName( 'sid ').Value:=i;
ADOQuery1.Parameters.ParamByName( 'sname ').Value:= 'Test '+inttostr(i);
ADOQuery1.ExecSQL;
Inc(commit_count);
if commit_count=1000 then
begin
ADOConnection1.CommitTrans;
commit_count:=0;
end;
ProgressBar1.Position:=ProgressBar1.Position+1;
Application.ProcessMessages;
except
ADOConnection1.RollbackTrans;
end;
end;
end;