Home » SQL & PL/SQL » SQL & PL/SQL » Declaration of an associative array (On behalf of amrutha2004)
Declaration of an associative array [message #274287] Mon, 15 October 2007 06:40 Go to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
received via PM

In case we need to store some decimal numbers(such as 'amount') in the associative array,can we declare the associative array this way....

TYPE loan_table IS TABLE OF NUMBER(13,2) INDEX BY binary_integer;
a_num_loan loan_table;


please reply. Thank you.
Why don't you try it out?

SQL> set serverout on
SQL> DECLARE
  2    TYPE my_table_type IS TABLE OF NUMBER(12,3) INDEX BY BINARY_INTEGER;
  3    my_table my_table_type;
  4  BEGIN
  5    my_table(5) := 123.5;
  6    dbms_output.put_line(to_char(my_table(5)));
  7  END;
  8  /
123.5

PL/SQL procedure successfully completed.

SQL>


MHE
Re: Declaration of an associative array [message #274288 is a reply to message #274287] Mon, 15 October 2007 06:43 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
I just received the same thing and replied:
Quote:

Just try it:

SQL> declare
  2    TYPE loan_table IS TABLE OF NUMBER(13,2) INDEX BY binary_integer;
  3    a_num loan_table;
  4  begin
  5    a_num(1) := 10.30;
  6    a_num(2) := 123456;
  7    a_num(3) := 1.023456;
  8    for i in 1..a_num.count loop
  9      dbms_output.put_line(a_num(i));
 10    end loop;
 11  end;
 12  /
10.3
123456
1.02

PL/SQL procedure successfully completed.

Regards
Michel


OP, you can do this only once.
You did it, DON'T TRY IT AGAIN AND POST YOUR QUESTION IN FORUMS.

Regards
Michel
Re: Declaration of an associative array [message #274292 is a reply to message #274288] Mon, 15 October 2007 07:29 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
It seems that many of us received the same private message ...
Re: Declaration of an associative array [message #274346 is a reply to message #274292] Mon, 15 October 2007 13:07 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
yep, me too...

Makes you wonder. I'd say it takes less time to post one question then to pm the top-n (..., I won't say anything).
Previous Topic: How to do Bulk copy in PL/SQL
Next Topic: data architecture question about indexes for foreign keys
Goto Forum:
  


Current Time: Thu Feb 13 22:55:44 CST 2025