{"id":7913,"date":"2020-07-13T10:12:46","date_gmt":"2020-07-13T16:12:46","guid":{"rendered":"http:\/\/www.designandexecute.com\/designs\/?p=7913"},"modified":"2020-07-13T10:17:39","modified_gmt":"2020-07-13T16:17:39","slug":"oracle-example-of-associative-array","status":"publish","type":"post","link":"https:\/\/www.designandexecute.com\/designs\/oracle-example-of-associative-array\/","title":{"rendered":"Oracle &#8211; Example of Associative Array"},"content":{"rendered":"<h1>This is light weight way to manage key value pairs<\/h1>\n<p>DECLARE<\/p>\n<p>&nbsp;&nbsp;&nbsp; TYPE my_array is TABLE OF x INDEX BY BINARY_INTEGER;<\/p>\n<p>&nbsp;&nbsp;&nbsp; <em>l_my_array<\/em> my_array ;<\/p>\n<p>&nbsp;&nbsp;&nbsp; <strong>l_index<\/strong> BINARY_INTEGER;<\/p>\n<p>BEGIN<\/p>\n<p><strong>&nbsp;&nbsp;&nbsp; &#8211;To traverse the array:<\/strong><\/p>\n<p><strong>&nbsp;&nbsp;&nbsp; l_index<\/strong> := array_name.FIRST;<\/p>\n<p>&nbsp;&nbsp;&nbsp; WHILE <strong>l_index<\/strong> IS NOT NULL LOOP<\/p>\n<p><span class=\"hljs-comment\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; access the array element<\/span><\/p>\n<p><span class=\"hljs-comment\">&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; dbms_output.put_line(&nbsp; <\/span><span class=\"hljs-comment\"><em>l_my_array<\/em> (l_index)<\/span>);<\/p>\n<p><strong>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; l_index<\/strong> := l_my_array .NEXT(l_index);<\/p>\n<p><span class=\"hljs-keyword\">&nbsp;&nbsp;&nbsp; END<\/span> <span class=\"hljs-keyword\">LOOP<\/span>;<\/p>\n<p>EXCEPTION<\/p>\n<p>&nbsp;&nbsp;&nbsp; WHEN OTHERS THEN<br>&nbsp;&nbsp;&nbsp; DBMS_OUTPUT.PUT_LINE(SQLERRM);<br>&nbsp;&nbsp;&nbsp; DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);<br>&nbsp;&nbsp; RAISE;<br>&nbsp;&nbsp; ROLLBACK; <\/p>\n<p>END;<\/p>\n<p><\/p>\n<p><a href=\"https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-associative-array\/\">https:\/\/www.oracletutorial.com\/plsql-tutorial\/plsql-associative-array\/<\/a><\/p>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is light weight way to manage key value pairs DECLARE &nbsp;&nbsp;&nbsp; TYPE my_array is TABLE OF x INDEX BY BINARY_INTEGER; &nbsp;&nbsp;&nbsp; l_my_array my_array ; &nbsp;&nbsp;&nbsp; l_index BINARY_INTEGER; BEGIN &nbsp;&nbsp;&nbsp; &#8211;To traverse the array: &nbsp;&nbsp;&nbsp; l_index := array_name.FIRST; &nbsp;&nbsp;&nbsp; WHILE l_index IS NOT NULL LOOP &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212; access the array element &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; dbms_output.put_line(&nbsp; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":7921,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-7913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bi-data-warehouse"],"jetpack_featured_media_url":"https:\/\/www.designandexecute.com\/designs\/wp-content\/uploads\/2020\/07\/oracle-db580x224_logo.jpg","_links":{"self":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts\/7913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/comments?post=7913"}],"version-history":[{"count":5,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts\/7913\/revisions"}],"predecessor-version":[{"id":7922,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/posts\/7913\/revisions\/7922"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/media\/7921"}],"wp:attachment":[{"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/media?parent=7913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/categories?post=7913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.designandexecute.com\/designs\/wp-json\/wp\/v2\/tags?post=7913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}