14prepare_batch.mql 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. -- ============================================================
  2. -- Prepare Batch 操作测试
  3. -- ============================================================
  4. -- 1. 通过 loop 模拟 prepare batch 插入
  5. insert into /test/aaa/test_prepare (p_name, p_int) values (?, ?)
  6. /**
  7. scope(mql)
  8. loop(5)
  9. params("prep_batch_{%d,mqli}", {%d,mqli})
  10. **/
  11. ;
  12. -- 2. 验证 prep batch 插入结果
  13. select p_name, p_int from /test/aaa/test_prepare where p_name=^'prep_batch'
  14. /**
  15. output()
  16. **/
  17. ;
  18. -- 3. 再次使用 loop 做批量 update
  19. update /test/aaa/test_prepare set p_int=? where p_name=?
  20. /**
  21. scope(mql)
  22. loop(5)
  23. params(999, "prep_batch_{%d,mqli}")
  24. **/
  25. ;
  26. -- 4. 验证批量更新
  27. select p_name, p_int from /test/aaa/test_prepare where p_name=^'prep_batch'
  28. /**
  29. output()
  30. **/
  31. ;
  32. -- 5. 批量删除(删除前 3 条)
  33. delete from /test/aaa/test_prepare where p_name=?
  34. /**
  35. scope(mql)
  36. loop(3)
  37. params("prep_batch_{%d,mqli}")
  38. **/
  39. ;
  40. -- 6. 验证批量删除
  41. select p_name from /test/aaa/test_prepare where p_name=^'prep_batch'
  42. /**
  43. output()
  44. **/
  45. ;