请各位帮忙,JAVA-SQL的问题

fengyes123 2006-11-10 10:09:19
本人是初学java,遇见了一个问题,希望高手能解答.

在SQL2000数据库中

有一张二维表,其中一列,列名为TransactionType,有三个数据UPDATE,INSERT,DELETE.
还有一列,列名为Time,其中记录了时间.

TransactionType
UPDATE
INSERT
DELETE

我现在希望能完成如下功能:
1.按照Time来降序.
2.然后通过判断TransactionType中的事务类型,依照时间顺序来执行UPDATE,INSERT或DELETE.

主要问题在第二步,如何在结果集中比较数据库表中的内容?

请各位帮忙谢谢~
...全文
201 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengyes123 2006-11-10
  • 打赏
  • 举报
回复
额.谢谢楼上.
我试试.~~
hdhmail2000 2006-11-10
  • 打赏
  • 举报
回复
用游标,你查下帮助就能解决了
jianghuxiaoxiami 2006-11-10
  • 打赏
  • 举报
回复
关注:)
fengyes123 2006-11-10
  • 打赏
  • 举报
回复
最好能有代码实例.

我比较笨.

:(

谢谢各位
hdhmail2000 2006-11-10
  • 打赏
  • 举报
回复
帮助上的游标的用法:
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

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧