Oracle Magazine, May/June 2018
Database Developer PL SQL RECURSIVE LOOPING THROUGH AN ARRAY Some JSON arrays are simple lists of scalars or even objects But many arrays have other arrays within them And with these arrays with nested arrays you might want to iterate through all the leaves in that hierarchical structure The easiest way to do that is with recursion Lets build a procedure to do just that First I create a put_ line helper procedure to display the string indented to show its place in the JSON array hierarchy ORACLE MAGAZINE MAY JUNE 2018 72 CREATE OR REPLACE PROCEDURE put_ line string_ in IN VARCHAR2 pad_ in IN INTEGER DEFAULT 0 IS BEGIN DBMS_ OUTPUT put_ line LPAD pad_ in 3 string_ in END My version of DBMS_ OUTPUT put_ line is used in several places in the following json_ array_ traversal procedure CREATE OR REPLACE PROCEDURE json_ array_ traversal json_ document_ in IN CLOB leaf_ action_ in IN VARCHAR2 level_ in IN INTEGER DEFAULT 0 IS l_ array json_ array_ t 1 2 3 4 5 6
You must have JavaScript enabled to view digital editions.