473,385 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

URGENT: VARRAY as Input/Output variable

I wrote a small package and it successfully compiled. When I test the
package it was giving an error. Please look into the below code. Can
anyone written Varrays as input and output variables in a procedure.
I need to assign values directly to the varray, does it possible? How
?

Thanks in advance.

Brief explanation:-
Java program call the below package by giving two input parameters one
is array another is number. This package should return two arrays one
with address information and another with error codes if any address
not found.

SQL> create type acct_obj as object (acct_num varchar2(20),
2 name1 varchar2(20)
3 )
4 /

Type created.

SQL>
SQL> create type acct_arr is VARRAY(6) OF acct_obj
2 /

Type created.

SQL>
SQL> create type addr_obj as object (
2 name1 varchar2(20),
3 addr_line1 varchar2(30),
4 addr_line2 varchar2(30),
5 addr_line3 varchar2(30),
6 city varchar2(20),
7 state varchar2(2),
8 zip varchar2(7)
9 )
10 /

Type created.

SQL>
SQL> create type addr_arr is VARRAY(6) OF addr_obj
2 /

Type created.

SQL>
SQL> create type return_arr is VARRAY(6) of number(6)
2 /

Type created.

SQL>
SQL> --======================================
SQL> --Package Creation
SQL> --======================================
SQL> CREATE OR REPLACE PACKAGE acct_retr AS
2
3 PROCEDURE find_addr (
4 i_number IN NUMBER,
5 i_name1 IN acct_arr,
6 o_addr OUT addr_arr,
7 o_return_code OUT return_arr
8 );
9 END acct_retr;
10 /

Package created.

SQL>
SQL> CREATE OR REPLACE PACKAGE BODY acct_retr AS
2
3 error_in_input NUMBER(2) := 2;
4
5 PROCEDURE find_addr (
6 i_number IN NUMBER,
7 i_name1 IN acct_arr,
8 o_addr OUT addr_arr,
9 o_return_code OUT return_arr
10 )
11 IS
12 Invalid_range EXCEPTION;
13 BEGIN
14 IF (NVL(i_number,0) <= 0 or i_number > 6) THEN
15 RAISE invalid_range;
16 END IF;
17 --
18 -- Retrieve from database and send account address
19 -- array to the calling program with if any error codes
20 --
21 EXCEPTION
22 WHEN invalid_range THEN
23 o_return_code(1) := error_in_input;
24 o_addr := NULL;
25 END find_addr;
26
27 END acct_retr;
28 /

Package body created.

SQL> declare
2 i_number NUMBER(2):= NULL;
3 i_name1 acct_arr;
4 o_addr addr_arr;
5 o_return_code return_arr;
6 begin
7 acct_retr.find_addr(i_number, i_name1,
8 o_addr, o_return_code);
9 dbms_output.put_line(NVL(o_addr(1).name1, 'No Issuer'));
10 dbms_output.put_line('Return Code '||o_return_code(1));
11 end;
12 /
declare
*
ERROR at line 1:
ORA-06531: Reference to uninitialized collection
ORA-06512: at "OPS$UBTDEV.ACCT_RETR", line 23
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at line 7
Jul 19 '05 #1
1 7547
Jan
before you start to do something with collections in your
procedure/function, you should initialize that object.
E.g. for your OUT parameter o_addr, you should put there:

o_addr:=addr_arr();
Jan
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PedroSilva | last post by:
I need to know how to get a collection (varray), basically it's an array of chars with size of 9999 positions, from oracle so I can use it as an array with php. There's very little documentation...
8
by: uc_sk | last post by:
Hello All I am a newbie to PERL language...If i have a file with data of form abcd 4 {1,2,3} 3 lmn- 3 {12,18,19,22} 4 then i can read them as... ($list $listTotal $set $noElements) = split /...
1
by: monika | last post by:
hi ... I have an asp page which has 3 buttons. <p align="center"><input class="button" type="button" onClick="location='welStudent.asp';" value="Click to write a new story"></p> <p...
0
by: KVN Chary | last post by:
I'm facing one problem with Varrays. I have to use Varrays as input and output parameters in a procedure. When I assign a value to Varray, Oracle errored out as and asking for Initialize the...
4
by: Gregory Edigaroff | last post by:
Hello, Everybody! Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest, so I believe somebody have a solution for it. I need either a full...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
3
by: Tony Marston | last post by:
I am using PHP 4.4.4 with Oracle 10g Express Edition on Windows XP. I am trying to emulate in Oracle the SET datatype in MySQL and the ARRAY datatype in PostgreSQL I have the created a...
77
by: Hans Schneider | last post by:
1. in the prg bellow what vars are stored on stack, heap, data segment? int i; void main() { int j; int *k = (void *)malloc(1); }
5
pradeepjain
by: pradeepjain | last post by:
This is the function that i use to remove all quotes and things.But this time its giving error y i dont know. function sanitize($input){ if(is_array($input)){ foreach($input as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.