各位老大帮帮忙啊,关于Tquery的cachedupdates的问题,急!!!(100分)

  • 主题发起人 主题发起人 hxantman
  • 开始时间 开始时间
H

hxantman

Unregistered / Unconfirmed
GUEST, unregistred user!
环境:windows 2000 pro 数据库也安装上面
数据库:DB2 7.2
delphi5 用bde连接数据库
Database1+query1+datasource1+updatasql1
问题:起用程序,对连接的数据表进行编辑,运行post操作,一切正常,当再次对数据表进行编辑后,运行post操作,就出错了,跟踪一下,发现是运行在ApplyUpdates出错,提示gernale sql error.我做了很多实验,同样的操作在sql server 和oracle上是没问题,请各位老大指点啊。
procedure TForm1.Query1AfterPost(DataSet: TDataSet);
begin
with Query1 do begin
Database1.StartTransaction;
try
//Showmessage(Sql.Text);
ApplyUpdates;
Database1.Commit;
except
on E: Exception do begin
Showmessage(E.Message + inttostr(E.HelpContext));
Database1.Rollback;
// on E: Exception do showmessage(E.Message+ inttostr(E.HelpContext));
raise;
end;
end;
// CommitUpdates;
end;

end;


update huxtest
set
CLASS_ID = :CLASS_ID,
CLASS_NAME = :CLASS_NAME,
DEPARTMENT_ID = :DEPARTMENT_ID,
SECTION = :SECTION
where
CLASS_ID = :OLD_CLASS_ID


insert into huxtest
(CLASS_ID, CLASS_NAME, DEPARTMENT_ID, SECTION)
values
(:CLASS_ID, :CLASS_NAME, :DEPARTMENT_ID, :SECTION)


 
是不是多人同時使用該數據庫???
 
没有啊,是我正在开发的程序啊,只有我一个人用。还有我跟踪了一下,出现了以下信息。哪位大哥帮帮忙啊,真急
1 10:58:12 Log started for: Project2
2 10:58:35 SQL Vendor: DB2 - SQLSetConnectOption
3 10:58:35 SQL Prepare: DB2 - update huxtest
set
CLASS_ID = ?,
CLASS_NAME = ?,
DEPARTMENT_ID = ?,
SECTION = ?
where
CLASS_ID = ?

4 10:58:35 SQL Vendor: DB2 - SQLAllocStmt
5 10:58:35 SQL Vendor: DB2 - SQLPrepare
6 10:58:35 SQL Data In: DB2 - Param = 1, Name = , Type = fldZSTRING, Precision = 5, Scale = 0, Data = sdfsd
7 10:58:35 SQL Data In: DB2 - Param = 2, Name = , Type = fldZSTRING, Precision = 4, Scale = 0, Data = 1212
8 10:58:35 SQL Data In: DB2 - Param = 3, Name = , Type = fldZSTRING, Precision = 3, Scale = 0, Data = 123
9 10:58:35 SQL Data In: DB2 - Param = 4, Name = , Type = fldZSTRING, Precision = 3, Scale = 0, Data = 111
10 10:58:35 SQL Data In: DB2 - Param = 5, Name = , Type = fldZSTRING, Precision = 5, Scale = 0, Data = sdfsd
11 10:58:35 SQL Execute: DB2 - update huxtest
set
CLASS_ID = ?,
CLASS_NAME = ?,
DEPARTMENT_ID = ?,
SECTION = ?
where
CLASS_ID = ?

12 10:58:35 SQL Vendor: DB2 - SQLBindParameter
13 10:58:35 SQL Vendor: DB2 - SQLBindParameter
14 10:58:35 SQL Vendor: DB2 - SQLBindParameter
15 10:58:35 SQL Vendor: DB2 - SQLBindParameter
16 10:58:35 SQL Vendor: DB2 - SQLBindParameter
17 10:58:35 SQL Vendor: DB2 - SQLExecute
18 10:58:35 SQL Vendor: DB2 - SQLNumResultCols
19 10:58:35 SQL Vendor: DB2 - SQLRowCount
20 10:58:35 SQL Data In: DB2 - Rows affected = 1
21 10:58:35 SQL Transact: DB2 - XACT Commit
22 10:58:35 SQL Vendor: DB2 - SQLTransact
23 10:58:35 SQL Vendor: DB2 - SQLSetConnectOption
24 10:59:55 SQL Vendor: DB2 - SQLSetConnectOption
25 11:00:23 SQL Data In: DB2 - Param = 1, Name = , Type = fldZSTRING, Precision = 5, Scale = 0, Data = sdfsd
26 11:00:23 SQL Data In: DB2 - Param = 2, Name = , Type = fldZSTRING, Precision = 4, Scale = 0, Data = 2121
27 11:00:23 SQL Data In: DB2 - Param = 3, Name = , Type = fldZSTRING, Precision = 3, Scale = 0, Data = 123
28 11:00:23 SQL Data In: DB2 - Param = 4, Name = , Type = fldZSTRING, Precision = 3, Scale = 0, Data = 111
29 11:00:23 SQL Data In: DB2 - Param = 5, Name = , Type = fldZSTRING, Precision = 5, Scale = 0, Data = sdfsd
30 11:00:23 SQL Stmt: DB2 - Reset
31 11:00:23 SQL Vendor: DB2 - SQLFreeStmt
32 11:00:23 SQL Execute: DB2 - update huxtest
set
CLASS_ID = ?,
CLASS_NAME = ?,
DEPARTMENT_ID = ?,
SECTION = ?
where
CLASS_ID = ?

33 11:00:23 SQL Vendor: DB2 - SQLBindParameter
34 11:00:23 SQL Error: DB2 -
35 11:00:23 SQL Error: DB2 - Unmapped SQL Error Code: 0
36 11:00:23 SQL Stmt: DB2 - Reset
37 11:13:35 SQL Transact: DB2 - XACT Abort
38 11:13:35 SQL Vendor: DB2 - SQLTransact
39 11:13:35 SQL Vendor: DB2 - SQLSetConnectOption
 
应该是
34 11:00:23 SQL Error: DB2 -
绑定变量的时候出错了,哪位能帮解决啊
 
自己顶一下啊,真没人帮我吗?
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
654
import
I
I
回复
0
查看
647
import
I
后退
顶部