简体   繁体   中英

wrong number or types of arguments in call to procedure (PLS00306)

create or replace procedure flight_search(
v_source in flights.origin_ap%type,
v_destination in flights.destination_ap%type,
v_date in flights.depart_date%type,
v_flightid out flights.flightid%type,
v_fare out flights.fare%type)
 is
cursor search_flight is SELECT flightid FROM flights
where v_source = origin_ap and v_destination = destination_ap and v_date = 
depart_date;
begin

open search_flight;
loop
fetch search_flight into v_flightid;
exit when search_flight%NOTFOUND;
dbms_output.put_line('Leaves from - ' || v_source || '. Arrives at - ' || 
v_destination || '. Fare - ' || v_fare);
end loop;
close search_flight;
end;

executing by

execute flight_search('JFK', 'LHR', '11/25/18');

Getting wrong number or types of arguments in call to flight_search. I am assuming it has something to do with the flightid and fare variables.

Your procedure has 5 formal arguments, and your call only has 3. You need to supply somewhere for the out variables to go. As you seem to be using SQL*Plus or SQL Developer, judging by the execute , you can use bind variables and then print those out after the call:

variable l_flightid number;
variable l_fare number;

execute flight_search('JFK', 'LHR', date '2018-11-25', l_flightid, l_fare);

print l_flightid

I've also changed the third argument to an actual date, rather than a string which has to be implicitly converted to a date using your current session NLS settings. I've used a date literal , but you could also use to_date() with a string literal and a suitable format mask.

Incidentally, you aren't currently populating v_fare . so I haven't bothered printing that variable after the call; and it isn't obvious where it would come from. And you might want to consider using an implicit cursor loop instead of an explicit one.

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