14prepare_batch.mql 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. onerror(continue,'invalid value for int field')
  16. **/
  17. ;
  18. -- 2. 验证 prep batch 插入结果
  19. select p_name, p_int from /test/aaa/test_prepare where p_name=^'prep_batch'
  20. /**
  21. output()
  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. onerror(continue)
  35. **/
  36. ;
  37. -- 4. 验证批量更新
  38. select p_name, p_int from /test/aaa/test_prepare where p_name=^'prep_batch'
  39. /**
  40. output()
  41. **/
  42. ;
  43. -- 5. 批量删除
  44. /**
  45. scope(mql)
  46. loop(3)
  47. beforerun(set(prep_name, concat('prep_batch_', mqli)))
  48. **/
  49. ;
  50. delete from /test/aaa/test_prepare where p_name=?
  51. /**
  52. params(prep_name)
  53. onerror(continue)
  54. **/
  55. ;
  56. -- 6. 验证批量删除
  57. select p_name from /test/aaa/test_prepare where p_name=^'prep_batch'
  58. /**
  59. output()
  60. **/
  61. ;