如何动态定义一个cursor名字啊?
例如:DECLARE cursor_name DYNAMIC CURSOR FOR SQLSA;
如何每次动态生成cursor-name啊?就象
int li_1
li_1=li_1+1
多谢了啊。
问题点数:0、回复次数:10Top
1 楼wxhacker(为了。。。)回复于 2004-08-04 11:18:29 得分 0
写个函数,参数为游标名
Top
2 楼jxc(GameHeart)回复于 2004-08-04 11:34:24 得分 0
建议你根据sql语句,动态创建Datastore来处理。Top
3 楼Hanson_bati_zhu(欺世盗名之徒)回复于 2004-08-04 11:35:08 得分 0
为什么要动态生成呢?
这个游标已经是Dynamic(动态)的了
Top
4 楼lzheng2001(1加1)回复于 2004-08-04 11:38:38 得分 0
用动态游标不行吗? 楼主想实现什么功能呀Top
5 楼benjaminz(RockDJ)回复于 2004-08-04 15:27:40 得分 0
因为在一个script里游标的名字是不能重复的,楼主想省事,呵呵Top
6 楼10975037(猩猩)回复于 2004-08-05 19:41:10 得分 0
楼主的意思是不是从数据库中取数据放到游标中,数据有多个,你想一个游标名存储一个数据,那么数据是多个相应的游标名也是多个(有不为什么要动态生成游标名,百思不解)
-------------------------------------------------------------------
如果是我说的意思,看看下面的代码功能就知道什么意思了
sqlca.autocommit=true
string czy100
string cursor1
cursor1=sle_1.text
declare cursor1 cursor for select distinct username from mima;
open cursor1;
fetch cursor1 into :czy100;
do while sqlca.sqlcode=0
integer li_rtn
li_rtn = CreateDirectory ('c:\'+czy100)
If li_rtn = 1 Then
MessageBox('提示信息',+'c:\'+czy100 + '目录创建成功!')
Else
MessageBox('提示信息',+'c:\'+czy100 + '目录创建失败!')
End if
fetch cursor1 into :czy100;
loop
close cursor1;
sqlca.autocommit=falseTop
7 楼bomber2001(沧海飘舟)回复于 2004-08-05 19:59:12 得分 0
upTop
8 楼yansongonline(小嵩在线)回复于 2004-08-08 17:51:47 得分 0
Hanson_bati_zhu 说出了我的心声啊!Top
9 楼yansongonline(小嵩在线)回复于 2004-08-08 17:56:38 得分 0
to 10975037(猩猩):其实你那样定义,cursor还是一个名。
我要作一个嵌套,有两个函数f_1,f_2,其中f_1调用f_2。如果cursor可以动态生成,那么就只用写一个函数f_1,它每次调用自己。
f_1 为:
string ls_sql,str_code
transaction lt_1
long ll_lev,ll_int
ls_sql="select amcode from am_data where AMUP='"+ls_code+"' and month='" + gs_year_month +"'"
DECLARE cursor_1 DYNAMIC CURSOR FOR SQLSA;
PREPARE SQLSA FROM :ls_sql USING SQLCA;
OPEN DYNAMIC cursor_1;
DO
fetch cursor_1 into :str_code;
if sqlca.sqlcode<>0 and sqlca.sqlcode<>100 then
messagebox("´íÎó","Êý¾Ý¿âÁ¬½Ó´íÎó"+sqlca.sqlerrtext)
close cursor_1;
return (1)
exit
elseif sqlca.sqlcode=100 then
close cursor_1;
return (1)
exit
end if
ll_lev=tv_1.InsertItemlast(ll_tv,str_code,1)
ll_int=f_2(str_code,tv_1,ll_lev)
LOOP WHILE sqlca.sqlcode<>100
close cursor_1;
return(0)
f_2为:
string ls_sql,str_code
transaction lt_1
long ll_lev,ll_int
ls_sql="select amcode from am_data where AMUP='"+ls_code+"' and month='" + gs_year_month +"'"
DECLARE cursor_1 DYNAMIC CURSOR FOR SQLSA;
PREPARE SQLSA FROM :ls_sql USING SQLCA;
OPEN DYNAMIC cursor_1;
DO
fetch cursor_1 into :str_code;
if sqlca.sqlcode<>0 and sqlca.sqlcode<>100 then
messagebox("´íÎó","Êý¾Ý¿âÁ¬½Ó´íÎó"+sqlca.sqlerrtext)
close cursor_1;
return (1)
exit
elseif sqlca.sqlcode=100 then
close cursor_1;
return (1)
exit
end if
ll_lev=tv_1.InsertItemlast(ll_tv,str_code,1)
LOOP WHILE sqlca.sqlcode<>100
close cursor_1;
return(0)Top
10 楼yansongonline(小嵩在线)回复于 2004-08-08 17:59:09 得分 0
to 10975037猩猩:
游标名:cursor1 不会随着sle_1的值变化而改变的。
Top




