正在更新数据字段 4gl
Update data field in progress 4gl
有人可以帮我吗?
我想做的就是更新 table 中的一个字段,例如满足特定条件的会员编号。
例如:我有一个会员号码列表。如果列表中的号码与 table 中的会员号码匹配 - 我们什么都不做。
如果不匹配 - 然后我们将会员编号更改为存储在我的输入 CSV 中的另一个编号。 (我知道这听起来像是回到前面,但这只是一个类比)
所以本质上我是在问 - 如何更新数据库中的字段 table?这似乎不起作用:
def stream inputStream.
def stream outStream.
def var abcData as char extent 4 no-undo.
def var vl-XYZ# as integer.
def var vl-link# as integer.
def var vl-orig-ABC# as char.
def var vl-new-ABC# as char.
/* def var vl-error as char. */
def var vl-match as char.
def var vl-status as char.
def buffer bMembers for members.
input stream inputStream from "/home/abc.csv".
output stream outStream to "/home/xyz.csv".
export stream outStream delimiter "'" "ABCID" "Match".
repeat:
assign
abcData = "".
import stream inputStream delimiter "'" abcData.
assign
vl-link# = integer(abcdata[1])
vl-XYZ# = integer(abcData[2])
vl-orig-ABC# = string(abcData[3])
vl-new-ABC# = string(abcData[4]) .
for each account no-lock where account.link# = vl-link#,
First members no-lock where members.XYZ# = vl-XYZ#:
if members.abc# = vl-orig-ABC# then
assign
vl-status = "Needs amending".
if members.abc# <> vl-orig-ABC# then
assign
vl-status = "No action needed"
members.abc# = vl-new-ABC#.
export stream outStream delimiter "'" vl-link# vl-XYZ# vl-orig-ABC# members.abc# vl-status
]
更新成员记录的问题将出现在 FOR EACH 中。您需要对成员 table 使用 EXCLUSIVE-LOCK 才能更新记录。
for each account no-lock where account.link# = vl-link#,
First members EXCLUSIVE-LOCK where members.XYZ# = vl-XYZ#:
成员table的选择标准似乎也不对,在一个加入的FOR EACH语句中,第二个table应该依赖于第一个,比如
for each account no-lock where account.link# = vl-link#,
First members EXCLUSIVE-LOCK where members.<somefield of members> = account.<matchine ield in account>
AND members.XYZ# = vl-XYZ#:
有人可以帮我吗?
我想做的就是更新 table 中的一个字段,例如满足特定条件的会员编号。
例如:我有一个会员号码列表。如果列表中的号码与 table 中的会员号码匹配 - 我们什么都不做。
如果不匹配 - 然后我们将会员编号更改为存储在我的输入 CSV 中的另一个编号。 (我知道这听起来像是回到前面,但这只是一个类比)
所以本质上我是在问 - 如何更新数据库中的字段 table?这似乎不起作用:
def stream inputStream.
def stream outStream.
def var abcData as char extent 4 no-undo.
def var vl-XYZ# as integer.
def var vl-link# as integer.
def var vl-orig-ABC# as char.
def var vl-new-ABC# as char.
/* def var vl-error as char. */
def var vl-match as char.
def var vl-status as char.
def buffer bMembers for members.
input stream inputStream from "/home/abc.csv".
output stream outStream to "/home/xyz.csv".
export stream outStream delimiter "'" "ABCID" "Match".
repeat:
assign
abcData = "".
import stream inputStream delimiter "'" abcData.
assign
vl-link# = integer(abcdata[1])
vl-XYZ# = integer(abcData[2])
vl-orig-ABC# = string(abcData[3])
vl-new-ABC# = string(abcData[4]) .
for each account no-lock where account.link# = vl-link#,
First members no-lock where members.XYZ# = vl-XYZ#:
if members.abc# = vl-orig-ABC# then
assign
vl-status = "Needs amending".
if members.abc# <> vl-orig-ABC# then
assign
vl-status = "No action needed"
members.abc# = vl-new-ABC#.
export stream outStream delimiter "'" vl-link# vl-XYZ# vl-orig-ABC# members.abc# vl-status
]
更新成员记录的问题将出现在 FOR EACH 中。您需要对成员 table 使用 EXCLUSIVE-LOCK 才能更新记录。
for each account no-lock where account.link# = vl-link#,
First members EXCLUSIVE-LOCK where members.XYZ# = vl-XYZ#:
成员table的选择标准似乎也不对,在一个加入的FOR EACH语句中,第二个table应该依赖于第一个,比如
for each account no-lock where account.link# = vl-link#,
First members EXCLUSIVE-LOCK where members.<somefield of members> = account.<matchine ield in account>
AND members.XYZ# = vl-XYZ#: