Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Within the first afternoon I found 2 of the 3 needed solutions, and the 3rd came to me over the weekend!..."

Geography

Where in the world do Tek-Tips members come from?
getjbb (MIS)
30 Jul 12 19:13
I am using 9i:

My problem is I am trying to return a table from a function, but I am getting the following error:

ORA-06550: line 2, column 36:
PLS-00302: component 'GET_TAB_PRODS' must be declared
ORA-06550: line 2, column 10:
PL/SQL: Item ignored
ORA-06550: line 8, column 3:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 8, column 3:
PL/SQL: Statement ignored

It may be the way I declared my table as an object:

CREATE OR REPLACE TYPE get_mort_prods AS OBJECT (
rec_id number(4),
loan_num number(12),
no_days number(4),
pap_code varchar2(8),
prod_code varchar2(2),
name varchar2(75)
);

create or replace type get_tab_prods as table of get_mort_prods;

==============================================

The function within the package, get_mort_info:

Create or Replace package body pk_mortg_get_info is

FUNCTION get_mort_info ( a_account IN varchar2) return get_mort_prods IS

a_mortg get_tab_prods;
i_count number := 0;

cursor c_mort is
SELECT distinct rec_id, loan_num, no_days, pap_code, prod_code, name
FROM mort
WHERE mort.acct_no = a_account
ORDER BY rec_id;

BEGIN



FOR r_mort in c_mort LOOP
i__count := i_count + 1;
a_mortg(i_count).rec_id := r_mort.rec_id;
a_mortg(i_count).loan_num := r_mort.loan_num;
a_mortg(i_count).no_days := r_mort.no_days;
a_mortg(i_count).pap_code := r_mort.pap_code;
a_mortg(i_count).prod_code := r_mort.prod_code;
a_mortg(i_count).name := r_mort.name);
END LOOP;


----

return a_mortg;


END get_mort_info;


END pk_mortg_get_info ;

I did grant permission for, 'GET_TAB_PRODS' , but that did not help. Is there any other way of during this with out implementing declaring objects if that is the problem?

Thanks.

Dagon (MIS)
2 Aug 12 11:01
Are all the objects being created by the same user?

Dagon (MIS)
2 Aug 12 11:01
All objects and packages, that is.

Dagon (MIS)
2 Aug 12 11:13
BTW, even if you get round the problem of it not recognising your type, the code is completely wrong. You haven't initialized your objects or extended them to add new elements. I've put together an example to show you how you should use object types in PL/SQL.

CODE

CREATE OR REPLACE TYPE get_mort_prods AS OBJECT (
rec_id number(4),
loan_num number(12),
no_days number(4),
pap_code varchar2(8),
prod_code varchar2(2),
name varchar2(75)
);
/

create or replace type get_tab_prods as table of get_mort_prods;
/

Create or Replace package pk_mortg_get_info is
FUNCTION get_mort_info ( a_account IN varchar2) return get_mort_prods;
end; 
/

Create or Replace package body pk_mortg_get_info is
FUNCTION get_mort_info ( a_account IN varchar2) return get_mort_prods IS
a_mortg get_tab_prods := get_tab_prods();
m get_mort_prods;
begin
  for i in 1..5 loop
    a_mortg.extend;
    a_mortg(i) := get_mort_prods(i, i, i, 'X'||i, 'Y'||i, 'Z'||i);
  end loop;
  m := a_mortg(5);
  return m;
end;
END;
/

declare
  m get_mort_prods;
begin
  M := pk_mortg_get_info.get_mort_info('xx');
  dbms_output.put_line(m.rec_id);
end;
/ 

getjbb (MIS)
3 Aug 12 7:45
Thanks, Dagon

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close