<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Passing Array to Oracle : JDBC in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-array-to-oracle-jdbc/m-p/2837201#M721215</link>
    <description>Hello,&lt;BR /&gt;&lt;BR /&gt;From my notes:&lt;BR /&gt;&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;You just need to declare new types.  You can have types that are tables of &lt;BR /&gt;a RECORD or types that are tables of SCALARS.  I'll show both below.  See the &lt;BR /&gt;plsql guide for how to declare record types -- you can do them based on an &lt;BR /&gt;existing table structure, a cursor structure or by explicity defining your own &lt;BR /&gt;record type.&lt;BR /&gt;&lt;BR /&gt;Note that if you are calling emp_report from a 3gl such as Pro*C, OCI, VB, etc &lt;BR /&gt;(eg: anything OTHER then plsql) you will need to use tables of scalars -- NOT a &lt;BR /&gt;table of records as tables of records cannot be bound to by a 3gl.  Also, I &lt;BR /&gt;suggest only use charArray's if you are going to be calling this from a 3gl -- &lt;BR /&gt;if you made a table of NUMBER or a table of DATE -- we would expect you to send &lt;BR /&gt;the INTERNAL format of a number (22 byte field in an obscure format) or a date &lt;BR /&gt;(7 byte, equally obscure format).  Best to send strings and let the conversions &lt;BR /&gt;take place.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; create or replace package demo_pkg&lt;BR /&gt;  2  as&lt;BR /&gt;  3      type empArray is table of emp%rowtype index by binary_integer;&lt;BR /&gt;  4  &lt;BR /&gt;  5      type charArray is table of varchar2(255) index by binary_integer;&lt;BR /&gt;  6  &lt;BR /&gt;  7  &lt;BR /&gt;  8      procedure emp_report( p_inputs in empArray );&lt;BR /&gt;  9  &lt;BR /&gt; 10      procedure emp_report( p_empno  in charArray,&lt;BR /&gt; 11                            p_deptno in charArray,&lt;BR /&gt; 12                            p_sal    in charArray,&lt;BR /&gt; 13                            p_job    in charArray );&lt;BR /&gt; 14  &lt;BR /&gt; 15  end;&lt;BR /&gt; 16  /&lt;BR /&gt;&lt;BR /&gt;Package created.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; create or replace package body demo_pkg&lt;BR /&gt;  2  as&lt;BR /&gt;  3      procedure emp_report( p_inputs in empArray )&lt;BR /&gt;  4      is&lt;BR /&gt;  5      begin&lt;BR /&gt;  6          for i in 1 .. p_inputs.count loop&lt;BR /&gt;  7              dbms_output.put_line( 'Empno = ' || p_inputs(i).empno ||&lt;BR /&gt;  8                                    ' Deptno = ' || p_inputs(i).deptno );&lt;BR /&gt;  9          end loop;&lt;BR /&gt; 10      end;&lt;BR /&gt; 11  &lt;BR /&gt; 12  &lt;BR /&gt; 13      procedure emp_report( p_empno  in charArray,&lt;BR /&gt; 14                            p_deptno in charArray,&lt;BR /&gt; 15                            p_sal    in charArray,&lt;BR /&gt; 16                            p_job    in charArray )&lt;BR /&gt; 17      is&lt;BR /&gt; 18      begin&lt;BR /&gt; 19          for i in 1 .. p_empno.count loop&lt;BR /&gt; 20              dbms_output.put_line( 'Empno = ' || p_empno(i) ||&lt;BR /&gt; 21                                    ' Deptno = ' || p_deptno(i) );&lt;BR /&gt; 22          end loop;&lt;BR /&gt; 23      end;&lt;BR /&gt; 24  &lt;BR /&gt; 25  &lt;BR /&gt; 26  &lt;BR /&gt; 27  end;&lt;BR /&gt; 28  /&lt;BR /&gt;&lt;BR /&gt;Package body created.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; set serveroutput on&lt;BR /&gt;yd@8i&amp;gt; declare&lt;BR /&gt;  2      my_data   demo_pkg.empArray;&lt;BR /&gt;  3  begin&lt;BR /&gt;  4      my_data(1).empno := 1234;&lt;BR /&gt;  5      my_data(1).deptno := 10;&lt;BR /&gt;  6  &lt;BR /&gt;  7      my_data(2).empno := 4567;&lt;BR /&gt;  8      my_data(2).deptno := 20;&lt;BR /&gt;  9  &lt;BR /&gt; 10      demo_pkg.emp_report( my_data );&lt;BR /&gt; 11  end;&lt;BR /&gt; 12  /&lt;BR /&gt;Empno = 1234 Deptno = 10&lt;BR /&gt;Empno = 4567 Deptno = 20&lt;BR /&gt;&lt;BR /&gt;PL/SQL procedure successfully completed.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; declare&lt;BR /&gt;  2      my_empnos   demo_pkg.charArray;&lt;BR /&gt;  3      my_deptno   demo_pkg.charArray;&lt;BR /&gt;  4      empty       demo_pkg.charArray;&lt;BR /&gt;  5  begin&lt;BR /&gt;  6      my_empnos(1) := 1234;&lt;BR /&gt;  7      my_deptno(1) := 10;&lt;BR /&gt;  8  &lt;BR /&gt;  9      my_empnos(2) := 4567;&lt;BR /&gt; 10      my_deptno(2) := 20;&lt;BR /&gt; 11  &lt;BR /&gt; 12      demo_pkg.emp_report( my_empnos, my_deptno, empty, empty );&lt;BR /&gt; 13  end;&lt;BR /&gt; 14  /&lt;BR /&gt;Empno = 1234 Deptno = 10&lt;BR /&gt;Empno = 4567 Deptno = 20&lt;BR /&gt;&lt;BR /&gt;PL/SQL procedure successfully completed.&lt;BR /&gt;&lt;BR /&gt;&lt;/QUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Yogeeraj</description>
    <pubDate>Fri, 01 Nov 2002 05:50:31 GMT</pubDate>
    <dc:creator>Yogeeraj_1</dc:creator>
    <dc:date>2002-11-01T05:50:31Z</dc:date>
    <item>
      <title>Passing Array to Oracle : JDBC</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-array-to-oracle-jdbc/m-p/2837200#M721214</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;Suppose I want to call a procedure which would take an array of string and insert it into a specific table.&lt;BR /&gt;&lt;BR /&gt;I can get a resultset via an out parameter by declaring a ref cursor and executing some select statement for it in the procedure. But how to do the reverse i.e. passing an array to the procedure?&lt;BR /&gt;&lt;BR /&gt;Any ideas?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;Soumen Ghosh</description>
      <pubDate>Fri, 01 Nov 2002 03:46:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-array-to-oracle-jdbc/m-p/2837200#M721214</guid>
      <dc:creator>Soumen Ghosh</dc:creator>
      <dc:date>2002-11-01T03:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: Passing Array to Oracle : JDBC</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/passing-array-to-oracle-jdbc/m-p/2837201#M721215</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;From my notes:&lt;BR /&gt;&lt;BR /&gt;&lt;QUOTE&gt;&lt;BR /&gt;You just need to declare new types.  You can have types that are tables of &lt;BR /&gt;a RECORD or types that are tables of SCALARS.  I'll show both below.  See the &lt;BR /&gt;plsql guide for how to declare record types -- you can do them based on an &lt;BR /&gt;existing table structure, a cursor structure or by explicity defining your own &lt;BR /&gt;record type.&lt;BR /&gt;&lt;BR /&gt;Note that if you are calling emp_report from a 3gl such as Pro*C, OCI, VB, etc &lt;BR /&gt;(eg: anything OTHER then plsql) you will need to use tables of scalars -- NOT a &lt;BR /&gt;table of records as tables of records cannot be bound to by a 3gl.  Also, I &lt;BR /&gt;suggest only use charArray's if you are going to be calling this from a 3gl -- &lt;BR /&gt;if you made a table of NUMBER or a table of DATE -- we would expect you to send &lt;BR /&gt;the INTERNAL format of a number (22 byte field in an obscure format) or a date &lt;BR /&gt;(7 byte, equally obscure format).  Best to send strings and let the conversions &lt;BR /&gt;take place.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; create or replace package demo_pkg&lt;BR /&gt;  2  as&lt;BR /&gt;  3      type empArray is table of emp%rowtype index by binary_integer;&lt;BR /&gt;  4  &lt;BR /&gt;  5      type charArray is table of varchar2(255) index by binary_integer;&lt;BR /&gt;  6  &lt;BR /&gt;  7  &lt;BR /&gt;  8      procedure emp_report( p_inputs in empArray );&lt;BR /&gt;  9  &lt;BR /&gt; 10      procedure emp_report( p_empno  in charArray,&lt;BR /&gt; 11                            p_deptno in charArray,&lt;BR /&gt; 12                            p_sal    in charArray,&lt;BR /&gt; 13                            p_job    in charArray );&lt;BR /&gt; 14  &lt;BR /&gt; 15  end;&lt;BR /&gt; 16  /&lt;BR /&gt;&lt;BR /&gt;Package created.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; create or replace package body demo_pkg&lt;BR /&gt;  2  as&lt;BR /&gt;  3      procedure emp_report( p_inputs in empArray )&lt;BR /&gt;  4      is&lt;BR /&gt;  5      begin&lt;BR /&gt;  6          for i in 1 .. p_inputs.count loop&lt;BR /&gt;  7              dbms_output.put_line( 'Empno = ' || p_inputs(i).empno ||&lt;BR /&gt;  8                                    ' Deptno = ' || p_inputs(i).deptno );&lt;BR /&gt;  9          end loop;&lt;BR /&gt; 10      end;&lt;BR /&gt; 11  &lt;BR /&gt; 12  &lt;BR /&gt; 13      procedure emp_report( p_empno  in charArray,&lt;BR /&gt; 14                            p_deptno in charArray,&lt;BR /&gt; 15                            p_sal    in charArray,&lt;BR /&gt; 16                            p_job    in charArray )&lt;BR /&gt; 17      is&lt;BR /&gt; 18      begin&lt;BR /&gt; 19          for i in 1 .. p_empno.count loop&lt;BR /&gt; 20              dbms_output.put_line( 'Empno = ' || p_empno(i) ||&lt;BR /&gt; 21                                    ' Deptno = ' || p_deptno(i) );&lt;BR /&gt; 22          end loop;&lt;BR /&gt; 23      end;&lt;BR /&gt; 24  &lt;BR /&gt; 25  &lt;BR /&gt; 26  &lt;BR /&gt; 27  end;&lt;BR /&gt; 28  /&lt;BR /&gt;&lt;BR /&gt;Package body created.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; set serveroutput on&lt;BR /&gt;yd@8i&amp;gt; declare&lt;BR /&gt;  2      my_data   demo_pkg.empArray;&lt;BR /&gt;  3  begin&lt;BR /&gt;  4      my_data(1).empno := 1234;&lt;BR /&gt;  5      my_data(1).deptno := 10;&lt;BR /&gt;  6  &lt;BR /&gt;  7      my_data(2).empno := 4567;&lt;BR /&gt;  8      my_data(2).deptno := 20;&lt;BR /&gt;  9  &lt;BR /&gt; 10      demo_pkg.emp_report( my_data );&lt;BR /&gt; 11  end;&lt;BR /&gt; 12  /&lt;BR /&gt;Empno = 1234 Deptno = 10&lt;BR /&gt;Empno = 4567 Deptno = 20&lt;BR /&gt;&lt;BR /&gt;PL/SQL procedure successfully completed.&lt;BR /&gt;&lt;BR /&gt;yd@8i&amp;gt; &lt;BR /&gt;yd@8i&amp;gt; declare&lt;BR /&gt;  2      my_empnos   demo_pkg.charArray;&lt;BR /&gt;  3      my_deptno   demo_pkg.charArray;&lt;BR /&gt;  4      empty       demo_pkg.charArray;&lt;BR /&gt;  5  begin&lt;BR /&gt;  6      my_empnos(1) := 1234;&lt;BR /&gt;  7      my_deptno(1) := 10;&lt;BR /&gt;  8  &lt;BR /&gt;  9      my_empnos(2) := 4567;&lt;BR /&gt; 10      my_deptno(2) := 20;&lt;BR /&gt; 11  &lt;BR /&gt; 12      demo_pkg.emp_report( my_empnos, my_deptno, empty, empty );&lt;BR /&gt; 13  end;&lt;BR /&gt; 14  /&lt;BR /&gt;Empno = 1234 Deptno = 10&lt;BR /&gt;Empno = 4567 Deptno = 20&lt;BR /&gt;&lt;BR /&gt;PL/SQL procedure successfully completed.&lt;BR /&gt;&lt;BR /&gt;&lt;/QUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Yogeeraj</description>
      <pubDate>Fri, 01 Nov 2002 05:50:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/passing-array-to-oracle-jdbc/m-p/2837201#M721215</guid>
      <dc:creator>Yogeeraj_1</dc:creator>
      <dc:date>2002-11-01T05:50:31Z</dc:date>
    </item>
  </channel>
</rss>

