我就记得
repl all id with 代码 for 编码=编码
了,后面的条件不记得怎么写了,惭愧。
...全文
1113打赏收藏
丢人啊,忘光了,问个基础问题
数年没有用VFP了,什么都忘了,惭愧惭愧 我现有一个dbf文件,中有"编码"和"id"两个字段,另有一个dbf文件,中有"编码"和"代码"两个字段,现在要求按照编码匹配,把第二个文件中的"代码"字段的值赋给第一个文件的"id"字段,该如何写命令? 我就记得 repl all id with 代码 for 编码=编码 了,后面的条件不记得怎么写了,惭愧。
close all
use c:\temp\id.dbf alia id in 0 excl
select id
index on 编码 to tag bm
set order to tag bm
use c:\temp\p_point.dbf alia p_point in 0 excl
select p_point
scan all for seek(编码,'id')
replace id with id.代码
endscan
要这样,你试试看。
-------------------------
我流落在凄凉的世界里-孤苦伶仃
我过着动荡无助的生活-四处漂泊
好象不成功,我建立了一个程序文件来执行:
select c:\temp\id.dbf
index on 编码 to tag bm
set order to tag bm
select c:\temp\p_point.dbf
scan all for seek(编码,c:\temp\id.dbf)
replace id with id.代码
endscan
用replace一次性难以完成
select 表2
index on 编码 to tag bm
set order to tag bm
select 表1
scan all for seek(编码,'表2')
replace id with 表2.代码
endscan
-------------------------
我流落在凄凉的世界里-孤苦伶仃
我过着动荡无助的生活-四处漂泊
select 2 选择2号工作区
use 表2 &&打开表2
index on 编码 to bm &&按编码建立索引
select 1 &&选择1号工作区
use 表1 &&打开表1
index on 编码 to bm1 &&按编码建立索引
set real 编码 into b &&按编码建立关联
repl all id with b->代码 &&用2号工作区代码替换当前工作区的ID
close all
use c:\temp\id.dbf alia id in 0
use c:\temp\p_point.dbf alia p_point in 0 excl
select p_point
scan all
select id
locate for 编码=p_point.编码
select p_point
if !eof('id')
replace id with id.代码
endif
endscan
换一种方法试试看,这种方法速度会慢一些,顺便问一下,你的vfp用的是多少版本?
-------------------------
我流落在凄凉的世界里-孤苦伶仃
我过着动荡无助的生活-四处漂泊