- 论坛徽章:
- 0
|
我有一个222.txt文件,文件内容如下
1111111|2222|
2222222|2222|
1213233|1234|
2131231|2345|
想把此文件的第一个字段,和第二个字段的值分别付给如下语句中的
update basetab set accountleft=accountleft+%d where accountnumber=(select accountnumber from bind where number='%s')中的%s和%d处,并且把update语句写入temp.sql中
最后生成update basetab set accountleft=accountleft+2222 where accountnumber=(select accountnumber from bind where number='1111111');
update basetab set accountleft=accountleft+2222 where accountnumber=(select accountnumber from bind where number='2222222');
update basetab set accountleft=accountleft+1234 where accountnumber=(select accountnumber from bind where number='1213233');
update basetab set accountleft=accountleft+2345 where accountnumber=(select accountnumber from bind where number='2131231')
这样的文件,
我写了一个shell,内容如下:
awk -f creatsql.awk 2222.txt>temp.sql
tail temp.sql
其中creatsql.awk 内容如下:
BEGIN{
FS="|"
}
{
printf("update basetab set accountleft=accountleft+%d where accountnumber=(select accountnumber from bind where number='%s');\n",$2,$1)
}
但是执行不成功,请高手执教!谢谢! |
|