14prepare_batch.mql 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. -- ============================================================
  2. -- Prepare Batch 操作测试
  3. -- ============================================================
  4. -- 1. 通过 loop 模拟 prepare batch 插入
  5. -- 使用 beforerun 设置变量实现批量 prepare
  6. /**
  7. scope(mql)
  8. loop(5)
  9. beforerun(set(prep_name, concat('prep_batch_', mqli)), set(prep_val, mqli))
  10. **/
  11. ;
  12. insert into /test/aaa/test_prepare (p_name, p_int) values (?, ?)
  13. /**
  14. params(prep_name, prep_val)
  15. **/
  16. ;
  17. -- 2. 验证 prep batch 插入结果
  18. select p_name, p_int from /test/aaa/test_prepare where p_name prefix 'prep_batch'
  19. /**
  20. output()
  21. matchcount("p_name","prep_batch",5)
  22. **/
  23. ;
  24. -- 3. 再次使用 loop 做批量 update
  25. /**
  26. scope(mql)
  27. loop(5)
  28. beforerun(set(prep_name, concat('prep_batch_', mqli)), set(prep_val, 999))
  29. **/
  30. ;
  31. update /test/aaa/test_prepare set p_int=? where p_name=?
  32. /**
  33. params(prep_val, prep_name)
  34. **/
  35. ;
  36. -- 4. 验证批量更新
  37. select p_name, p_int from /test/aaa/test_prepare where p_name prefix 'prep_batch'
  38. /**
  39. output()
  40. **/
  41. ;
  42. -- 5. 批量删除
  43. /**
  44. scope(mql)
  45. loop(3)
  46. beforerun(set(prep_name, concat('prep_batch_', mqli)))
  47. **/
  48. ;
  49. delete from /test/aaa/test_prepare where p_name=?
  50. /**
  51. params(prep_name)
  52. **/
  53. ;
  54. -- 6. 验证批量删除
  55. select p_name from /test/aaa/test_prepare where p_name prefix 'prep_batch'
  56. /**
  57. output()
  58. **/
  59. ;