RowType In Function List [message #263151] |
Wed, 29 August 2007 04:06 |
lzfhope
Messages: 69 Registered: July 2006
|
Member |
|
|
hi,
I ask for help!
while i try to compile the main Function,Oracle return error code pls_00382 with message:Error: PLS-00382: expression is of wrong type.
Below is My Codes.
Main Function
F_main()
is
v_T tab%rowtype;
begin
update table_r set isvalid=f_getvalidvalue(v_t,Score);
commit;
end;
Sub Function
function F_GetValidValue(p_t in tab%rowtype,p_score in number) return int
is
begin
......
--return somthing here
end;
tso ,how to declare the variable in the main function? or how to change the sub function.
|
|
|
|
|
Re: RowType In Function List [message #263160 is a reply to message #263151] |
Wed, 29 August 2007 04:25 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Put you subfunction in the declaration section but this is only valid for function you want to use in PL/SQL.
If you want to use it in SQL you have to create a stored function and not a local one.
Regards
Michel
[Updated on: Wed, 29 August 2007 04:26] Report message to a moderator
|
|
|
|
Re: RowType In Function List [message #263430 is a reply to message #263367] |
Thu, 30 August 2007 01:05 |
|
Michel Cadot
Messages: 68718 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Quote: | Maybe you do not understand what i said.
|
Maybe you don't explain your problem correctly.
SQL> create or replace package pkg is
2 function f_main return int;
3 function f_sub (v_t t%rowtype) return int;
4 end;
5 /
Package created.
SQL> create or replace package body pkg is
2 function f_main return int is
3 v_t t%rowtype;
4 begin
5 return f_sub (v_t);
6 end;
7 function f_sub (v_t t%rowtype) return int is
8 begin return 1; end;
9 end;
10 /
Package body created.
SQL> select pkg.f_main from dual;
F_MAIN
----------
1
1 row selected.
There is no problem with rowtype.
Regards
Michel
[Updated on: Fri, 31 August 2007 00:37] Report message to a moderator
|
|
|
|
|
Re: RowType In Function List [message #263734 is a reply to message #263731] |
Thu, 30 August 2007 21:42 |
lzfhope
Messages: 69 Registered: July 2006
|
Member |
|
|
Here are the complete Codes:
Create table tab_T(id int);
create or replace package pkg_test is
Function F_main return int;
Function F_sub(p_t in tab%rowtype) return int;
end pkg_test;
create or replace package body pkg_test is
Function F_main return int
is
v_t tab%rowtype;
begin
update tab_t set id=to_char(f_sub(v_t));
return 100;
--return f_sub(v_t); --this will work fine.
end;
Function F_sub(p_t in tab%rowtype) return int
is
begin
return 100;
end;
end pkg_test;
|
|
|
|
|
|
|
|
|
|
|