{"action":"created","issue":{"url":"https://api.github.com/repos/pljson/pljson/issues/37","repository_url":"https://api.github.com/repos/pljson/pljson","labels_url":"https://api.github.com/repos/pljson/pljson/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/pljson/pljson/issues/37/comments","events_url":"https://api.github.com/repos/pljson/pljson/issues/37/events","html_url":"https://github.com/pljson/pljson/issues/37","id":145892875,"number":37,"title":"JSON_PARSER.next_char2 return value will duplicate first character as second character,when strlen=4000,8000...","user":{"login":"larkin88","id":5002717,"avatar_url":"https://avatars.githubusercontent.com/u/5002717?v=3","gravatar_id":"","url":"https://api.github.com/users/larkin88","html_url":"https://github.com/larkin88","followers_url":"https://api.github.com/users/larkin88/followers","following_url":"https://api.github.com/users/larkin88/following{/other_user}","gists_url":"https://api.github.com/users/larkin88/gists{/gist_id}","starred_url":"https://api.github.com/users/larkin88/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larkin88/subscriptions","organizations_url":"https://api.github.com/users/larkin88/orgs","repos_url":"https://api.github.com/users/larkin88/repos","events_url":"https://api.github.com/users/larkin88/events{/privacy}","received_events_url":"https://api.github.com/users/larkin88/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-05T05:40:08Z","updated_at":"2016-04-12T12:14:31Z","closed_at":null,"body":"for some time offset coming from 0, when string length equeue 4000,8000,substr(xxx,0, len) and substr(xxx,1, len) will occur , so JSON_PARSER.next_char2 return first character is error.  \r\n\r\nbug fix sample:\r\n```\r\n--------------------------------------\r\n  --2016-04-05 for conviect to test bug,defince variable instead 4000,\r\n  -- you can change to small number, etc. 10 to test \r\n  gn_load_cnt Number :=4000;\r\n \r\n\r\n /*type axe_sql_src is record (len number, offset number, src varchar2(10), s_clob clob); */\r\n  FUNCTION next_char(indx NUMBER,\r\n                     s    IN OUT NOCOPY axe_sql_src) RETURN VARCHAR2 AS\r\n  BEGIN\r\n    IF (indx > s.len)\r\n    THEN\r\n      RETURN NULL;\r\n    END IF;\r\n    --right offset?\r\n    \r\n    --IF (indx > 4000 + s.offset OR indx < s.offset)\r\n    --fix bug by larkin88 at 2016-04-05\r\n    IF (indx >= gn_load_cnt + s.offset OR indx < s.offset)\r\n    THEN\r\n      --load right offset\r\n      --s.offset := indx - (indx MOD 4000);\r\n      s.offset := indx - (indx MOD gn_load_cnt);\r\n      \r\n      --s.src    := dbms_lob.substr(s.s_clob, 4000, s.offset + 1);\r\n      --fix bug by larkin88 at 2016-04-05\r\n      s.src    := dbms_lob.substr(s.s_clob, gn_load_cnt, s.offset );\r\n      \r\n    END IF;\r\n    --read from s.src\r\n    \r\n    --RETURN substr(s.src, indx - s.offset, 1);\r\n     --fix bug by larkin88 at 2016-04-05\r\n    RETURN substr(s.src, indx - s.offset + 1, 1);\r\n    \r\n  END;\r\n    \r\n  \r\n  \r\n  FUNCTION prepareclob(buf CLOB) RETURN axe_sql_src AS\r\n    temp axe_sql_src;\r\n  BEGIN\r\n    temp.s_clob := buf;\r\n    --temp.offset := 0; fix bug by larkin88 at 2016-04-05\r\n    temp.offset := 1;\r\n    --temp.src    := dbms_lob.substr(buf, 4000, temp.offset + 1); fix bug by larkin88 at 2016-04-05\r\n    temp.src    := dbms_lob.substr(buf, gn_load_cnt, temp.offset);\r\n    temp.len    := dbms_lob.getlength(buf);\r\n    RETURN temp;\r\n  END;\r\n\r\n  FUNCTION preparevarchar2(buf VARCHAR2) RETURN axe_sql_src AS\r\n    temp axe_sql_src;\r\n  BEGIN\r\n    temp.s_clob := buf;\r\n    --temp.offset := 0; fix bug by larkin88 at 2016-04-05\r\n    temp.offset := 1;\r\n    --temp.src    := substr(buf, 1, 4000);\r\n    temp.src    := substr(buf, 1, gn_load_cnt);\r\n\r\n    temp.len    := length(buf);\r\n    RETURN temp;\r\n  END;\r\n ```"},"comment":{"url":"https://api.github.com/repos/pljson/pljson/issues/comments/208874645","html_url":"https://github.com/pljson/pljson/issues/37#issuecomment-208874645","issue_url":"https://api.github.com/repos/pljson/pljson/issues/37","id":208874645,"user":{"login":"jsumners","id":321201,"avatar_url":"https://avatars.githubusercontent.com/u/321201?v=3","gravatar_id":"","url":"https://api.github.com/users/jsumners","html_url":"https://github.com/jsumners","followers_url":"https://api.github.com/users/jsumners/followers","following_url":"https://api.github.com/users/jsumners/following{/other_user}","gists_url":"https://api.github.com/users/jsumners/gists{/gist_id}","starred_url":"https://api.github.com/users/jsumners/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsumners/subscriptions","organizations_url":"https://api.github.com/users/jsumners/orgs","repos_url":"https://api.github.com/users/jsumners/repos","events_url":"https://api.github.com/users/jsumners/events{/privacy}","received_events_url":"https://api.github.com/users/jsumners/received_events","type":"User","site_admin":false},"created_at":"2016-04-12T12:14:31Z","updated_at":"2016-04-12T12:14:31Z","body":"LOBs start at index 1, not 0 -- http://docs.oracle.com/cd/A91202_01/901_doc/appdev.901/a89852/dbms_23b.htm :\r\n\r\n> offset\r\n \t\r\n> Offset in bytes (for BLOBs) or characters (for CLOBs) from the start of the LOB (origin: 1). "}}