conv_eyetest_sorder.sql 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. drop procedure if exists conv_eyetest_sorder;
  2. DELIMITER //
  3. create procedure conv_eyetest_sorder()
  4. BEGIN
  5. -- Declare _json1 text;
  6. Declare _line_id int;
  7. Declare _not_found boolean;
  8. Declare _c1 varchar(64); Declare _c2 varchar(64); Declare _c3 varchar(64); Declare _c4 varchar(64); Declare _c5 varchar(64);
  9. Declare _c6 varchar(64); Declare _c7 varchar(64); Declare _c8 varchar(64); Declare _c9 varchar(64); Declare _c10 varchar(64);
  10. Declare _c11 varchar(64); Declare _c12 varchar(64); Declare _c13 varchar(64); Declare _c14 varchar(64); Declare _c15 varchar(64);
  11. Declare _c16 varchar(64); Declare _c17 varchar(64); Declare _c18 varchar(64); Declare _c19 varchar(64); Declare _c20 varchar(64);
  12. Declare _c21 varchar(64); Declare _c22 varchar(64); Declare _c23 varchar(64); Declare _c24 varchar(64); Declare _c25 varchar(64);
  13. Declare _line_cur_eyetest cursor for
  14. select
  15. c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25
  16. from zdb_eyetest
  17. -- where c1 = '2'
  18. order by c1 asc;
  19. Declare continue handler for
  20. not found set _not_found = true;
  21. set _not_found = false; -- 이것이 Multi cursor를 쓰는 핵심이다.
  22. open _line_cur_eyetest;
  23. loop_eyetest: loop
  24. fetch _line_cur_eyetest into
  25. _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8, _c9, _c10, _c11, _c12, _c13, _c14, _c15, _c16, _c17, _c18, _c19, _c20,
  26. _c21, _c22, _c23, _c24, _c25 ;
  27. if _not_found then leave loop_eyetest; end if;
  28. SET @json1 = '{
  29. "REyeLens": {
  30. "Sph": "",
  31. "Cyl": "",
  32. "Axis": "",
  33. "LongPd": "",
  34. "Add": "",
  35. "ShortPd": "",
  36. "BaseIo": "",
  37. "BaseUd": "",
  38. "BareEye": "",
  39. "Adjust": ""
  40. },
  41. "LEyeLens": {
  42. "Sph": "",
  43. "Cyl": "",
  44. "Axis": "",
  45. "LongPd": "",
  46. "Add": "",
  47. "ShortPd": "",
  48. "BaseIo": "",
  49. "BaseUd": "",
  50. "BareEye": "",
  51. "Adjust": ""
  52. },
  53. "RContLens": {
  54. "Sph": "",
  55. "Cyl": "",
  56. "Axis": "",
  57. "Add": "",
  58. "Bc": "",
  59. "Dia": "",
  60. "Kerato": "",
  61. "Prescript": "",
  62. "Adjust": ""
  63. },
  64. "LContLens": {
  65. "Sph": "",
  66. "Cyl": "",
  67. "Axis": "",
  68. "Add": "",
  69. "Bc": "",
  70. "Dia": "",
  71. "Kerato": "",
  72. "Prescript": "",
  73. "Adjust": ""
  74. },
  75. "Symptoms": "",
  76. "OldREyeLens": {
  77. "Sph": "",
  78. "Cyl": "",
  79. "Axis": "",
  80. "LongPd": "",
  81. "Add": "",
  82. "ShortPd": "",
  83. "BaseIo": "/",
  84. "BaseUd": "/",
  85. "BareEye": "",
  86. "Adjust": ""
  87. },
  88. "OldLEyeLens": {
  89. "Sph": "",
  90. "Cyl": "",
  91. "Axis": "",
  92. "LongPd": "",
  93. "Add": "",
  94. "ShortPd": "",
  95. "BaseIo": "/",
  96. "BaseUd": "/",
  97. "BareEye": "",
  98. "Adjust": ""
  99. },
  100. "CcREyeLens": {
  101. "Sph": "",
  102. "Cyl": "",
  103. "Axis": "",
  104. "LongPd": "",
  105. "Add": "",
  106. "ShortPd": "",
  107. "BaseIo": "/",
  108. "BaseUd": "/",
  109. "BareEye": "",
  110. "Adjust": ""
  111. },
  112. "CcLEyeLens": {
  113. "Sph": "",
  114. "Cyl": "",
  115. "Axis": "",
  116. "LongPd": "",
  117. "Add": "",
  118. "ShortPd": "",
  119. "BaseIo": "/",
  120. "BaseUd": "/",
  121. "BareEye": "",
  122. "Adjust": ""
  123. },
  124. "FixEye": 0,
  125. "Stereosia": 0,
  126. "ColorVision": 0,
  127. "OdImGrid": 0,
  128. "OsImGrid": 0,
  129. "Screen": {
  130. "Shielding": {
  131. "Long": "",
  132. "Short": ""
  133. },
  134. "FourDot": {
  135. "Long": 0,
  136. "Short": 0,
  137. "LongStr": "",
  138. "ShortStr": ""
  139. },
  140. "Converge": {
  141. "Normal": 0,
  142. "Str": ""
  143. },
  144. "Near": {
  145. "OdStr": "",
  146. "OsStr": ""
  147. },
  148. "Easy": {
  149. "OuStr": "",
  150. "OdStr": "",
  151. "OsStr": ""
  152. }
  153. },
  154. "BroadH": {
  155. "X": "[]",
  156. "Y": "[]",
  157. "Drage": "[]"
  158. },
  159. "Bincular": {
  160. "Location": {
  161. "LongHori": "",
  162. "LongVert": "",
  163. "ShortHori": "",
  164. "ShortVert": ""
  165. },
  166. "Relative": {
  167. "Pra": "",
  168. "Nra": ""
  169. },
  170. "Lag": 0,
  171. "Aca": "",
  172. "Fusion": {
  173. "LongBo": {
  174. "Clo": "",
  175. "Dis": "",
  176. "Rec": ""
  177. },
  178. "LongBi": {
  179. "Clo": "",
  180. "Dis": "",
  181. "Rec": ""
  182. },
  183. "LongOdBd": {
  184. "Dis": "",
  185. "Rec": ""
  186. },
  187. "LongOdBu": {
  188. "Dis": "",
  189. "Rec": ""
  190. },
  191. "LongOsBd": {
  192. "Dis": "",
  193. "Rec": ""
  194. },
  195. "LongOsBu": {
  196. "Dis": "",
  197. "Rec": ""
  198. },
  199. "ShortBo": {
  200. "Clo": "",
  201. "Dis": "",
  202. "Rec": ""
  203. },
  204. "ShortBi": {
  205. "Clo": "",
  206. "Dis": "",
  207. "Rec": ""
  208. },
  209. "ShortOdBd": {
  210. "Dis": "",
  211. "Rec": ""
  212. },
  213. "ShortOdBu": {
  214. "Dis": "",
  215. "Rec": ""
  216. },
  217. "ShortOsBd": {
  218. "Dis": "",
  219. "Rec": ""
  220. },
  221. "ShortOsBu": {
  222. "Dis": "",
  223. "Rec": ""
  224. }
  225. }
  226. },
  227. "Pameter": {
  228. "Oh": {
  229. "R": "",
  230. "L": ""
  231. },
  232. "Pd": {
  233. "R": "",
  234. "L": ""
  235. },
  236. "Distance": {
  237. "R": "",
  238. "L": ""
  239. },
  240. "Inset": {
  241. "R": "",
  242. "L": ""
  243. },
  244. "Face": "",
  245. "Tilt": "",
  246. "Length": ""
  247. },
  248. "Payment": {
  249. "CardCompany": "",
  250. "CashReceipt": "",
  251. "GiftCard": ""
  252. }
  253. }';
  254. update dbr_sorder set json1 =
  255. json_replace(@json1,
  256. '$.REyeLens.Sph', _c2,
  257. '$.REyeLens.Cyl', _c3,
  258. '$.REyeLens.Axis', _c4,
  259. '$.REyeLens.LongPd', _c5,
  260. '$.REyeLens.Add', _c6,
  261. '$.REyeLens.ShortPd', _c7,
  262. '$.LEyeLens.Sph', _c8,
  263. '$.LEyeLens.Cyl', _c9,
  264. '$.LEyeLens.Axis', _c10,
  265. '$.LEyeLens.LongPd', _c11,
  266. '$.LEyeLens.Add', _c12,
  267. '$.LEyeLens.ShortPd', _c13,
  268. '$.RContLens.Sph', _c14,
  269. '$.RContLens.Cyl', _c15,
  270. '$.RContLens.Axis', _c16,
  271. '$.RContLens.Add', _c17,
  272. '$.RContLens.Bc', _c18,
  273. '$.RContLens.Dia', _c19,
  274. '$.LContLens.Sph', _c20,
  275. '$.LContLens.Cyl', _c21,
  276. '$.LContLens.Axis', _c22,
  277. '$.LContLens.Add', _c23,
  278. '$.LContLens.Bc', _c24,
  279. '$.LContLens.Dia', _c25
  280. )
  281. where id = _c1;
  282. end loop loop_eyetest;
  283. close _line_cur_eyetest;
  284. END;
  285. //
  286. DELIMITER ;
  287. call conv_eyetest_sorder();