对过程的调用中参数的数量或类型错误(PLS00306)

时间:2018-12-18 19:00:43

标签: sql oracle plsql procedure cursors

<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<!-- Materialize CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

<!-- Materialize JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

<!-- Material Icon Webfont -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">




<div class="row">
  <div class="col s12">
    <div class="row">
      <div class="input-field autocomplete_dynamic col s12">
        <i class="material-icons prefix">group</i>

        <div data-autocomplete-source='["Miss T","Mr C","Mr D","Medicine Take","Surgery Take"]' class="string optional chips" type="text" name="setting[team_name]" id="setting_team_name"></div>


      </div>
    </div>
  </div>
</div>




<div class="row">
  <div class="col s12">
    <div class="row">
      <div class="input-field autocomplete_dynamic col s12">
        <i class="material-icons prefix">group</i>

        <input class="string optional input-field" data-autocomplete-source='["Consultant Doctor","Ward Clerk","Nurse","Foundation Doctor (FY1)","Foundation Doctor (FY2)","Core Trainee Doctor (CT2)","Core Trainee Doctor (CT1)"]' type="text" name="setting[profession_name]"
          id="setting_profession_name">


        <label for="autocomplete-input">Select your role</label>
      </div>
    </div>
  </div>
</div>

执行
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;

在调用flight_search时得到错误的参数数目或类型。我假设它与flightid和fare变量有关。

1 个答案:

答案 0 :(得分:1)

您的过程有5个正式参数,而您的调用只有3个。您需要在某个地方提供out变量。好像您正在使用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

我还将第三个参数更改为实际日期,而不是必须使用当前会话NLS设置将其隐式转换为日期的字符串。我使用过date literal,但是您也可以将to_date()与字符串文字和合适的格式掩码一起使用。

顺便说一句,您当前未填充v_fare。这样我就不必在调用后打印该变量了;而且它的来源并不明显。您可能要考虑使用隐式游标循环而不是显式游标循环。