Chinaunix首页 | 论坛 | 博客
  • 博客访问: 310836
  • 博文数量: 42
  • 博客积分: 2718
  • 博客等级: 少校
  • 技术积分: 467
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-19 10:23
个人简介

青 田 酒 店 服 务 小 姐 价 格 186-6531-7773

文章分类

全部博文(42)

文章存档

2011年(36)

2010年(6)

分类: LINUX

2011-07-06 16:22:22

事务导出:
import_trans.sh
  1. TDIR="data/transaction"
  2. mkdir -pv "$TDIR" >/dev/null 2>&1
  3. tfile="data/tfile.txt"
  4. unlink "$tfile" >/dev/null 2>&1
  5. touch "$tfile" >/dev/null 2>&1
  6. mysql -uroot -pxxx cmdb -e "select t_transaction.Id, t_transaction.name, descinfo,borntime,count, t_user.user from t_transaction,t_user where t_transaction.valid = 1 and t_transaction.owner = t_user.Id" | awk '{if(NR>1)print$0}' | awk '{if(NF==7)print$0}' | while read ID NAME DESC DATE TIME COUNT OWNER
  7. do
  8.     NDIR="$TDIR/$ID"
  9.     mkdir -pv "$NDIR" >/dev/null 2>&1
  10.     echo "$NAME" > "$NDIR/name"
  11.     echo "$DESC" > "$NDIR/descinfo"
  12.     echo "$DATE $TIME" > "$NDIR/time"
  13.     echo "$COUNT" > "$NDIR/count"
  14.     echo "$OWNER" > "$NDIR/owner"
  15.     echo "$ID" >>"$tfile"
  16. done
  17. cat "$tfile" | while read transid
  18. do
  19.     NDIR="$TDIR/$transid"
  20.     mkdir -pv "$NDIR" >/dev/null 2>&1
  21.     unlink "$NDIR/polist" >/dev/null 2>&1
  22.     touch "$NDIR/polist"
  23.     if [ "$transid" -lt "1" ]
  24.     then
  25.         echo "error trans_id '$transid' " >> error.log
  26.         continue
  27.     fi
  28.     mysql -uroot -pxxx cmdb -e "select t_trans_pol.f_pol_id, t_trans_pol.idex, t_trans_pol.depd from t_trans_pol where t_trans_pol.f_tran_id = $transid and t_trans_pol.valid = 1 order by t_trans_pol.idex asc" | awk '{if(NR>1)print$0}' | while read pol idx depd
  29.     do
  30.         #echo "$transid-$pol-$depd"
  31.         echo "$pol $idx $depd" >> "$NDIR/polist"
  32.     done
  33.     
  34. done
  35. unlink "$tfile" >/dev/null 2>&1

执行完用tree看下结果:

 

  1. tree data/transaction/
  2. data/transaction/
  3. |-- 46
  4. | |-- count
  5. | |-- descinfo
  6. | |-- name
  7. | |-- owner
  8. | |-- polist
  9. | `-- time
  10. |-- 47
  11. | |-- count
  12. | |-- descinfo
  13. | |-- name
  14. | |-- owner
  15. | |-- polist
  16. | `-- time
  17. |-- 48
  18. | |-- count
  19. | |-- descinfo
  20. | |-- name
  21. | |-- owner
  22. | |-- polist
  23. | `-- time
  24. |-- 49
  25. | |-- count
  26. | |-- descinfo
  27. | |-- name
  28. | |-- owner
  29. | |-- polist
  30. | `-- time
  31. |-- 50
  32. | |-- count
  33. | |-- descinfo
  34. | |-- name
  35. | |-- owner
  36. | |-- polist
  37. | `-- time
  38. |-- 51
  39. | |-- count
  40. | |-- descinfo
  41. | |-- name
  42. | |-- owner
  43. | |-- polist
  44. | `-- time
  45. |-- 52
  46. | |-- count
  47. | |-- descinfo
  48. | |-- name
  49. | |-- owner
  50. | |-- polist
  51. | `-- time
  52. |-- 53
  53. | |-- count
  54. | |-- descinfo
  55. | |-- name
  56. | |-- owner
  57. | |-- polist
  58. | `-- time
  59. |-- 54
  60. | |-- count
  61. | |-- descinfo
  62. | |-- name
  63. | |-- owner
  64. | |-- polist
  65. | `-- time
  66. `-- 55
  67.     |-- count
  68.     |-- descinfo
  69.     |-- name
  70.     |-- owner
  71.     |-- polist
  72.     `-- time

  73. 10 directories, 60 files
阅读(7830) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~