fetch emp_w into :order_name;
do while sqlca.sqlcode=0
ddlb_1.additem(order_name)
fetch emp_w into :order_name;
loop
建议在程序中尽量避免使用游标,我有如下例程也许会对你有用:
//f_create_datastorenew
//ddlb_tmp 添加数据
//as_disp_table 显示列表名
//as_colname 显示数据列
//as_rtn_table 返回列表名
//as_rtn_colname 选取时返回值对应的列
//as_sql 生成DATASTORE的语法
//as_data[] 返回值
string error_syntaxfromSQL, error_create
string new_sql, new_syntax,ls_text,ls_coltype,ls_type
string ls_colname,ls_rtn
DataStore lds_data
Long i,ll_col
lds_data = Create DataStore
new_syntax = SQLCA.SyntaxFromSQL(as_sql, &
Style(Type=Form), error_syntaxfromSQL)
IF Len(error_syntaxfromSQL) > 0 THEN
// Display errors
MessageBox("提示信息", "语法错误"+error_syntaxfromSQL)
return -1
ELSE
// Generate new DataWindow
lds_data.Create(new_syntax, error_create)
IF Len(error_create) > 0 THEN
MessageBox("提示信息", "语法错误"+error_create)
return -1
END IF
END IF
lds_data.SetTransObject(SQLCA)
if lds_data.Retrieve() = 0 then return 0
ddlb_tmp.SetRedraw(false)
ddlb_tmp.Reset( )
if as_disp_table <> "" then
ls_colname = as_disp_table+"_"+as_colname
else
ls_colname = as_colname
end if
if as_rtn_table = "" then
ls_rtn = as_rtn_colname
else
ls_rtn = as_rtn_table+"_"+as_rtn_colname
end if
FOR i = 1 TO lds_data.RowCount()
ls_text = lds_data.GetItemString(i,ls_colname)
//获取列的数据类型
ls_coltype = lds_data.describe(ls_rtn+".coltype")
ls_type = upper(left(ls_coltype,3))
choose case ls_type
case LON,INT,NUM,REA,ULO
as_data[i] = STRING(lds_data.getitemnumber( i, ls_rtn))
case DEC
as_data[i] = String(lds_data.GetItemDecimal(i,ls_rtn))
case CHA
as_data[i] = lds_data.getitemstring( i, ls_rtn)
case DAT
as_data[i] = STRING(lds_data.getitemDATETIME( i, ls_rtn))
case TIM
as_data[i] = STRING(lds_data.getitemTIME( i, ls_rtn))
end choose
ddlb_tmp.additem(ls_text)
NEXT
ddlb_tmp.SetRedraw(true)
Destroy lds_data;
return 1
程序有问题,应改为:
do
fetch emp_w into :order_name;
if sqlca.sqlcode = 0 then
ddlb_1.additem(order_name)
end if
loop while sqlca.sqlcode=0
fetch emp_w into :order_name;
do while sqlca.sqlcode <> 100
ddlb_1.additem(order_name)
fetch emp_w into :order_name;
loop