惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
The GitHub Blog
The GitHub Blog
Recent Announcements
Recent Announcements
MyScale Blog
MyScale Blog
P
Proofpoint News Feed
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
H
Hacker News: Front Page
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
Microsoft Security Blog
Microsoft Security Blog
N
Netflix TechBlog - Medium
U
Unit 42
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Google Online Security Blog
Google Online Security Blog
Spread Privacy
Spread Privacy
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 热门话题
T
Tenable Blog
博客园 - 叶小钗
D
DataBreaches.Net
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
博客园 - 三生石上(FineUI控件)
量子位
P
Proofpoint News Feed
H
Help Net Security
Blog — PlanetScale
Blog — PlanetScale
宝玉的分享
宝玉的分享
Recorded Future
Recorded Future
The Register - Security
The Register - Security
F
Fortinet All Blogs
Engineering at Meta
Engineering at Meta
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Last Week in AI
Last Week in AI
S
Schneier on Security
V
Vulnerabilities – Threatpost
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
G
GRAHAM CLULEY
G
Google Developers Blog
月光博客
月光博客
V
V2EX
T
Troy Hunt's Blog
A
Arctic Wolf

博客园 - FilyCks

SQL动态条件查询例子 日期格式化函数 解决日志文件满造成的无法写入问题 数据库的日志文件 Delphi制作DLL SQLSERVER 日期函数及取当天数据 SQL语句导入导出大全 日期数据处理 按时间段统计数据(1) FastReport(5) FastReport(4) FastReport(3) FastReport(2) FastReport(1) 游标嵌套(个人笔记) FastReport 的初学感悟 查询表(个人笔记) 图片转换和读取(个人笔记) 自己研究出来的第一个游标
游标的一些例子
FilyCks · 2008-03-10 · via 博客园 - FilyCks

游标就   是相当于一个可以一条接一条读记录的指针.

如有一个表

num       score
1               80
2               70

在嵌入式的SQL中,就可以定义一个游标指向这个表如下

declare   cur   cursor   for   select   *   from   tab;   //定义游标
open   cur;               //打开游标,这时它指向第一条记录
while(1)
{
fetch   cur;                 //读取当前记录,并自动指向下一条记录
if(sqlca.sqlcode)break;         //记录都读完了,跳出
}
close   cur;       //关闭游标
free   cur;         //释放游标资源

declare my_cursor1 cursor for
select nContentId,dtEditTime from content where datepart(month,dtEditTime)='9' and datepart

(day,dtEditTime)='26'
open my_cursor1
declare @date sysname
declare @nID sysname
declare @tempDate datetime
fetch next from my_cursor1 into @nID,@date
while(@@fetch_status = 0)
begin
    set @tempDate =  dateadd(day,87,@date)
    --print @tempDate
    update Content set dtEditTime=@tempDate where nContentId = @nID
    fetch next from my_cursor1 into @nID,@date
end
close my_cursor1
deallocate my_cursor1用于把9月26日的日期改为:12月22日。
游标好比Sql中的指针。


declare @id nvarchar(20)  --定义变量来保存ID号
declare @A float                  --定义变量来保存值
declare mycursor cursor for select * from tb_c   --为所获得的数据集指定游标
open mycursor                   --打开游标
fetch next from mycursor  into @id,@A   --开始抓第一条数据
while(@@fetch_status=0)     --如果数据集里一直有数据
begin
 select tb_b.name,(tb_b.gz + @A) from tb_b where tb_b.id = @id   --开始做想做的事(什么更新

呀,删除呀)
        fetch next from mycursor into @id,@A     --跳到下一条数据
end
close mycursor        --关闭游标
deallocate mycursor  --删除游标