Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

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

  




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 Khokhar855
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Gitesh Trivedi322
  Gopu Gopi275
  neeraj sharma254
  Ramesh Jois245
  Bishal Khetan207






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software