• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Returning record in pl/sql function

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to write a function that returns a record which is defined inside it. WHen I compile, the error shown is
LINE/COL ERROR
-------- -----------------------------------------------------------------
0/0 PL/SQL: Compilation unit analysis terminated
2/53 PLS-00320: the declaration of the type of this expression is
incomplete or malformed
The function is given below.
1 create or replace function
2 compute_statistics(ssn1 in student.ssn%type) return stats_record
3 is
4 type mytype is record(first_name student.first_name%type, last_name
5 student.last_name%type,notlate number,late number);
6 stats_record mytype;
7 begin
8 select first_name,last_name into myrec.first_name,myrec_last_name from student
9 where ssn=ssn1;
10 select count(*) into myrec.notlate from transaction where status=1 and ssn=ssn1;
11 select count(*) into myrec.late from transaction where ssn=ssn1;
12 return (myrec);
13 exception
14 when no_data_found then
15 dbms_output.put_line('Invalid ssn or ssn not found');
16* end compute_statistics;
Plz help
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arun,
If you are using Oracle 8i (or above), use a "ref cursor". I suggest searching the following Web sites for "ref cursor":

http://otn.oracle.com

http://asktom.oracle.com

http://tahiti.oracle.com

Good Luck,
Avi.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic