23noerrinfo_skip.mql 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. -- ============================================================
  2. -- noerrinfo() skip() break continue 测试
  3. -- ============================================================
  4. -- 1. noerrinfo() - 不输出错误信息
  5. insert into /test/aaa/non_exist_xxx (name) values ('noerrinfo test')
  6. /**
  7. noerrinfo()
  8. onerror(continue,'not exist','not find','not found')
  9. **/
  10. ;
  11. -- 2. skip() - 跳过本语句(不执行)
  12. -- 此处不做 skip 演示,因为 skip() 会直接跳过,该语句不会在文件中有意义
  13. -- 3. continue - 配合 loop 使用,跳过当前迭代
  14. /**
  15. scope(mql)
  16. loop(5)
  17. **/
  18. ;
  19. -- 跳过 mqli=3 的迭代
  20. /**
  21. beforerun(case({%d,mqli},'3'))
  22. **/
  23. ;
  24. insert into /test/aaa/test_ext (e_name, e_value, e_text) values (concat('continue_test_', {%d,mqli}), {%d,mqli}, 'continue test - should skip mqli=3')
  25. /**
  26. onerror(continue)
  27. **/
  28. ;
  29. /**
  30. continue
  31. **/
  32. ;
  33. -- 验证 continue 跳过了 mqli=3
  34. select e_name from /test/aaa/test_ext where e_name=^'continue_test'
  35. /**
  36. output()
  37. **/
  38. ;
  39. -- 4. break - 配合 loop 使用,跳出循环
  40. /**
  41. scope(mql)
  42. loop(10)
  43. **/
  44. ;
  45. insert into /test/aaa/test_ext (e_name, e_value) values (concat('break_test_', {%d,mqli}), {%d,mqli})
  46. /**
  47. onerror(continue)
  48. **/
  49. ;
  50. -- 当 mqli>=3 时跳出
  51. /**
  52. beforerun(case({%d,mqli},'3'))
  53. **/
  54. ;
  55. /**
  56. break
  57. **/
  58. ;
  59. -- 验证 break 只执行了前 3 次
  60. select e_name from /test/aaa/test_ext where e_name=^'break_test'
  61. /**
  62. output()
  63. **/
  64. ;