简体   繁体   中英

How to correct '' PLS-00306: wrong number or types of arguments in call to ''

I want to call a function( ADD_PRICELIST ) that gets values in this one:

*the add_pricelist function complied successfully.

CREATE OR REPLACE FUNCTION PRICELIST_DATA(
  CPRIC_DATA_ID CUSTOMERS.CUSTOMERS_ID%TYPE,
  IPRIC_DATA_ID ITEMS.ITEMS_ID%TYPE
)
RETURN NUMBER AS
  L_PRICELIST_DATA_ID NUMBER;
BEGIN
      IF CPRIC_DATA_ID = IPRIC_DATA_ID THEN
        L_PRICELIST_DATA_ID := ADD_PRICELIST(ROUND(dbms_random.value(0,10),3)); 
      END IF;
  RETURN L_PRICELIST_DATA_ID;    
END PRICELIST_DATA;

Gives me:

PLS-00306: wrong number or types of arguments in call to ADD_PRICELIST

You ADD_PRICELIST function as the signature:

CREATE OR REPLACE FUNCTION ADD_PRICELIST(
  L_PLIST_CUST_ID CUSTOMERS.CUSTOMERS_ID%TYPE,
  L_PLIST_ITEMS_ID ITEMS.ITEMS_ID%TYPE,
  P_PRICELIST_PRICE NUMBER
) RETURN NUMBER

This takes 3 values and returns 1 value (which, as an aside, will always return NULL ).

You are only calling it with a single argument:

L_PRICELIST_DATA_ID := MINI_ERP.ADD_PRICELIST(
  ROUND(dbms_random.value(0,10),3)
); 

Which gives you the error:

PLS-00306: wrong number or types of arguments in call to ADD_PRICELIST

To solve this, you need to pass the other 2 arguments so that the function has all 3 expected arguments.

In order to call the function you have to provide a return value. That can be done either in PLSQL or in SQL

PLSQL

declare 
v_return number;
begin 
v_return := PRICELIST_DATA( CPRIC_DATA_ID => your customers id, IPRIC_DATA_ID => your items id) ;
dbms_output.put_line(v_return);
end;
/

SQL

select PRICELIST_DATA( CPRIC_DATA_ID => your customers id, IPRIC_DATA_ID => your items id) from dual ;

Or

select 
customers_id , 
items_id , 
PRICELIST_DATA( CPRIC_DATA_ID => your customers id, IPRIC_DATA_ID => your items id) from 
customers join items on ( customers.field = iterms.field)
-- where you filter ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM