表:file_name_t(filename,date,flag)
我是想统计一下表file_name的记录。为了不重复统计,每次统计完了要将flag由0置为1。所以我想每次取(fetch)一条记录就更新(update)光标(或游标cursor)处的记录来实现。注意还有另外一个存储过程在不停的插往表里插数据。谁能帮我写一些简单OCI8i的句子来实现他(当然了,连接数据库,打开光标和帮定等可以不写了)。谢了
我是想统计一下表file_name的记录。为了不重复统计,每次统计完了要将flag由0置为1。所以我想每次取(fetch)一条记录就更新(update)光标(或游标cursor)处的记录来实现。注意还有另外一个存储过程在不停的插往表里插数据。谁能帮我写一些简单OCI8i的句子来实现他(当然了,连接数据库,打开光标和帮定等可以不写了)。谢了
is
cursor t_sor is
select * from file_name_t;
--where 条件=v_id;
begin
for v_sor in t_sor loop
update file_name_t set flag=1 where filename=v_sor.filename;
end loop;
end name_pro;
为了唯一性,还是fetch rowid出来然后再用where rowid = "rowid"来updata比较好吧
is
cursor c_sor is
select * from file_name_t where flag=0 for update of flag;
begin
for v_sor in t_sor loop
...
update file_name_t set flag=1 where current of c_sor;
end loop;
end name_pro;
/