[英]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. 调用flight_search时得到错误的数量或参数类型。 I am assuming it has something to do with the flightid and fare variables. 我假设它与flightid和fare变量有关。
Your procedure has 5 formal arguments, and your call only has 3. You need to supply somewhere for the out
variables to go. 您的过程有5个形式参数,而调用只有3个。您需要在某个地方提供out
变量。 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: 好像您正在使用SQL * Plus或SQL Developer一样,通过execute
判断,可以使用绑定变量,然后在调用之后将其打印出来:
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. 我还将第三个参数更改为实际日期,而不是必须使用当前会话NLS设置将其隐式转换为日期的字符串。 I've used a date literal , but you could also use to_date()
with a string literal and a suitable format mask. 我使用了日期文字 ,但是您也可以将to_date()
与字符串文字和适当的格式掩码一起使用。
Incidentally, you aren't currently populating v_fare
. 顺便说一句,您当前未填充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. 您可能要考虑使用隐式游标循环而不是显式游标循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.