Topic: SQL*Plus and PL/SQL >> problem in Associative Arrays
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: problem in Associative Arrays |
| lvr |
Posted: May 29, 2008 11:30:33 PM |
Total Post: 12
Joined: May, 2008
|
SET SERVEROUTPUT ON
DECLARE
TYPE myname IS TABLE OF NUMBER INDEX BY VARCHAR2(80);
l_name myname;
l_pop NUMBER;
l_first varchar2(23);
BEGIN
-- Initialize Associative Array
l_name('sam') := 20000;
l_name('jose') := 750000;
-- Get Population for sam
l_pop := l_name('sam');
DBMS_OUTPUT.PUT_LINE('sam has: ' || l_pop );
--Get first Name
l_first := l_name.FIRST;
DBMS_OUTPUT.PUT_LINE('First name is: ' || l_first);
end;
/
when i run this program in 9.0.1.0.1 , i get this error
TYPE myname IS TABLE OF NUMBER INDEX BY VARCHAR2(80);
*
ERROR at line 2:
ORA-06550: line 2, column 45:
PLS-00222: no function with name 'VARCHAR2' exists in this scope
ORA-06550: line 2, column 5:
PL/SQL: Item ignored
ORA-06550: line 10, column 7:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 10, column 7:
PL/SQL: Statement ignored
ORA-06550: line 11, column 7:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 11, column 7:
PL/SQL: Statement ignored
ORA-06550: line 14, column 16:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 14, column 7:
PL/SQL: Statement ignored
|
|
|
Gitesh |
| Posted: May 30, 2008 07:08:11 AM | |
|
Total Post: 322
Joined: May, 2005
|
use PLS_INTEGER instead of varchar2(80) in TYPE myname IS TABLE OF NUMBER line.
|
|
|
|
|
lvr |
| Posted: May 30, 2008 08:15:41 AM | |
|
Total Post: 12
Joined: May, 2008
|
ya ..we can use binary_interger also ...then don't we use varchar2 in associative arrays....
any restrictions for using varchar2 datatype in element_type of associative arrays
|
|
|
|
|
Gitesh |
| Posted: May 30, 2008 10:50:50 PM | |
|
Total Post: 322
Joined: May, 2005
|
Yes you can use binary_integer also instead of PLS integer. What is the restrication that I don't know. You should refer PL/SQL documentation from Oracle.
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 855 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Gitesh Trivedi | 322 |
| Gopu Gopi | 275 |
| neeraj sharma | 254 |
| Ramesh Jois | 245 |
| Bishal Khetan | 207 |
|
|