当前页面: 开发资料首页 → J2SE 专题 → 通过判断TransactionType中的事务类型,依照时间顺序来执行UPDATE,INSERT或DELETE
通过判断TransactionType中的事务类型,依照时间顺序来执行UPDATE,INSERT或DELETE
摘要: 通过判断TransactionType中的事务类型,依照时间顺序来执行UPDATE,INSERT或DELETE
本人是初学java,遇见了一个问题,希望高手能解答.
在SQL2000数据库中
有一张二维表,其中一列,列名为TransactionType,有三个数据UPDATE,INSERT,DELETE.
还有一列,列名为Time,其中记录了时间.
TransactionType
UPDATE
INSERT
DELETE
我现在希望能完成如下功能:
1.按照Time来降序.
2.然后通过判断TransactionType中的事务类型,依照时间顺序来执行UPDATE,INSERT或DELETE.
主要问题在第二步,如何在结果集中比较数据库表中的内容?
请各位帮忙谢谢~
最好能有代码实例.
我比较笨.
:(
谢谢各位
关注:)
用游标,你查下帮助就能解决了
额.谢谢楼上.
我试试.~~
帮助上的游标的用法:
USE pubs
GO
-- Declare the variables to store the values returned by FETCH.
DECLARE @au_lname varchar(40), @au_fname varchar(20)
DECLARE authors_cursor CURSOR FOR
SELECT au_lname, au_fname FROM authors
WHERE au_lname LIKE "B%"
ORDER BY au_lname, au_fname
OPEN authors_cursor
-- Perform the first fetch and store the values in variables.
-- Note: The variables are in the same order as the columns
-- in the SELECT statement.
FETCH NEXT FROM authors_cursor
INTO @au_lname, @au_fname
-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- Concatenate and display the current values in the variables.
PRINT "Author: " + @au_fname + " " + @au_lname
-- This is executed as long as the previous fetch succeeds.
FETCH NEXT FROM authors_cursor
INTO @au_lname, @au_fname
END
CLOSE authors_cursor
DEALLOCATE authors_cursor
GO