14prepare_batch.mql 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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=^'prep_batch'
  19. /**
  20. output()
  21. **/
  22. ;
  23. -- 3. 再次使用 loop 做批量 update
  24. /**
  25. scope(mql)
  26. loop(5)
  27. beforerun(set(prep_name, concat('prep_batch_', mqli)), set(prep_val, 999))
  28. **/
  29. ;
  30. update /test/aaa/test_prepare set p_int=? where p_name=?
  31. /**
  32. params(prep_val, prep_name)
  33. **/
  34. ;
  35. -- 4. 验证批量更新
  36. select p_name, p_int from /test/aaa/test_prepare where p_name=^'prep_batch'
  37. /**
  38. output()
  39. **/
  40. ;
  41. -- 5. 批量删除
  42. /**
  43. scope(mql)
  44. loop(3)
  45. beforerun(set(prep_name, concat('prep_batch_', mqli)))
  46. **/
  47. ;
  48. delete from /test/aaa/test_prepare where p_name=?
  49. /**
  50. params(prep_name)
  51. **/
  52. ;
  53. -- 6. 验证批量删除
  54. select p_name from /test/aaa/test_prepare where p_name=^'prep_batch'
  55. /**
  56. output()
  57. **/
  58. ;