我如何从for 循环1 ,2 中取值 在for循环3里继续判断 我已经没思路了
以下是我从文本里导出来的数据
for 循环1 表名fru 取值苹果,香蕉,菠萝
for row=1 to data_cnt
max_a++
fileread(file_no,row_str)
temp_str=row_str
ps=pos(temp_str,"~t")
sid=long(left(temp_str,ps - 1))//sid
sm=long(mid(temp_str,ps +1))//sm
insert into fru(sid ,sm)
values(:sid,:sm)
next
for循环2 表名cor 取值green,Yellow,lightgreen
for row=1 to data_cnt
max_b++
fileread(file_no,row_str)
temp_str=row_str
ps=pos(temp_str,"~t")
cid=long(left(temp_str,ps - 1))//cid
color=long(mid(temp_str,ps +1))//color
insert into sm(cid,color)
values(:cid,:color)
next
for循环3 判断id=:l_id color=:l_color
insert into 数据库(id,color)
values (:l_id,:l_color)
for row=1 to data_cnt
max_b++
fileread(file_no,row_str)
temp_str=row_str
ps=pos(temp_str,"~t")
id=long(left(temp_str,ps - 1))//id
temp_str=mid(temp_str,ps+1)
ps=pos(temp_str,"~t")
sid=long(left(temp_str,ps - 1))//sid
cid=long(mid(temp_str,ps +1))//cid
select sid into :l_sid from fru where sm=:sm
if sqlca.sqlcode=100 then
insert into zh(id ,sid,cid)
values(:id,:max_sid,:max_cid)
end if
select cid into :l_cid from cor where color =:color
if sqlca.sqlcode=100 then
insert into zh(id ,sid,cid)
values(:id,:max_sid,:max_cid)
end if
insert into zh(id ,sid,cid)
values(:id,:l_sid,:l_cid )
next
假如都存在着对应的值 结果显示
苹果 green
香蕉 yellow
菠萝 lightgreen
------解决方案--------------------
你有一个txt,两列,
苹果 green
香蕉 yellow
菠萝 lightgreen
你要取得这些数据,把他们分别存储到数据库里,是不?
------解决方案--------------------
如果只是为了显示,没有必要插到数据库中,用三个数据窗口完全可以实现你的需求
数据窗口dw_1保存循环1中的数据
数据窗口dw_2保存循环2中的数据
在循环3中把处理后的结果放到数据窗口3中显示
------解决方案--------------------
这种问题可以有N种写法,LZ的写法,可以大量精简和优化。
存入数据库、数组、数据存储、多个DATAWINDOW、存入TXT文件等等。