Home » SQL & PL/SQL » SQL & PL/SQL » An error on a package .....
An error on a package ..... [message #205180] Thu, 23 November 2006 17:03 Go to next message
m_arafa
Messages: 36
Registered: June 2006
Member
hi all,

i type...

create or replace package pkg
as
type num_table_t is table of number;
function fnn (x num_table_t) return number;
end;
/

create or replace package body pkg
as
function fnn (x num_table_t)
return number;
is
begin
return x.count;
end;
end;
/


all things true ...


and then ..

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

select pkg.fnn(3,5,Cool
from dual;

that's return this error:
Wrong Number of argument .......

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

when I type:

declare
x pkg.num_table_t := pkg.num_table_t(3,5,8);
begin
dbms_output.put_line(x.count);
end;
/

that's return the result successfuly ....
why the first return error ...

finally, i want to pass parameters directly
as the first execution ...



thanks in advance .....


Re: An error on a package ..... [message #205198 is a reply to message #205180] Thu, 23 November 2006 19:13 Go to previous messageGo to next message
Barbara Boehmer
Messages: 8625
Registered: November 2002
Location: California, USA
Senior Member
Your second one worked because it was pl/sql using a pl/sql type. If you are going to use it in sql, it needs to be a sql type. You can't just pass it the numbers. You have to pass it a table of numbers.

SCOTT@10gXE> create or replace type num_table_t as table of number;
  2  /

Type created.

SCOTT@10gXE> create or replace package pkg
  2  as
  3    function fnn (x num_table_t) return number;
  4  end pkg;
  5  /

Package created.

SCOTT@10gXE> create or replace package body pkg
  2  as
  3    function fnn (x num_table_t) return number
  4    is
  5    begin
  6  	 return x.count;
  7    end fnn;
  8  end pkg;
  9  /

Package body created.

SCOTT@10gXE> select pkg.fnn (num_table_t (3, 5, 8)) from dual
  2  /

PKG.FNN(NUM_TABLE_T(3,5,8))
---------------------------
                          3

SCOTT@10gXE> 





Re: An error on a package ..... [message #206916 is a reply to message #205198] Sat, 02 December 2006 04:29 Go to previous message
m_arafa
Messages: 36
Registered: June 2006
Member
thanx ...
Barbara Boehmer
Previous Topic: How to get value from Exel sheet ang make a query in the Datebank
Next Topic: HOW TO UNLOCK TABLE USING ORACLE8I
Goto Forum:
  


Current Time: Sun Dec 04 08:57:44 CST 2016

Total time taken to generate the page: 0.07137 seconds