Home » SQL & PL/SQL » SQL & PL/SQL » Default value in Array
Default value in Array [message #2] Wed, 02 January 2002 01:26 Go to next message
Bhagwan Singh
Messages: 23
Registered: December 2001
Junior Member
Hi,
Iam creating a small pl/sql statement where Iam creating an table array and wants to assign some default values inside that.it gives error.
Declare
Type str_type is table of varchar2(15) not null index by binary_integer;
arr str_type;
begin
dbms_output.put_line(arr.count);
end;
How can I assign default values inside array 'arr' between 'declare' and 'begin' statment?
please help.
bhaggs

----------------------------------------------------------------------
Re: Default value in Array [message #3 is a reply to message #2] Wed, 02 January 2002 02:43 Go to previous message
Frank Naude
Messages: 4579
Registered: April 1998
Senior Member
Hi,

You can declare the table as a CONSTANT and assign table values to it. Look at this example...

set serveroutput on

DECLARE
TYPE str_type IS TABLE OF VARCHAR2(15) NOT NULL; -- index by binary_integer;
arr CONSTANT str_type := str_type('strVal1', 'strVal2', 'strVal3');
BEGIN
DBMS_OUTPUT.PUT_LINE(arr.COUNT);
END;
/

Best regards

Frank Naude

----------------------------------------------------------------------
Previous Topic: Need Help For Trigger
Next Topic: screen messages
Goto Forum:
  


Current Time: Fri Apr 19 02:36:48 CDT 2024