我正在尝试创建一个程序,我可以找出一些利率价格等。这里有一点摘录。
但是,我收到一条错误消息:检查'call due_form附近的语法(在amtDue double中,在extPrice double'中
变量的范围是否不正确?可能是什么问题?任何建议表示赞赏。
create procedure due_form(in amtDue double
, in extPrice double
, in discAmt double
, in discPrice double
, in p_taxRate double
, out p_msg varchar(255))
begin
set p_msg := concat(
'Amount Due ' , amtDue , '\n'
, 'Ext Price ', extPrice, '\n'
, 'Disc Amount ', discAmt, '\n'
, 'After Discount ', discPrice, '\n'
, 'Sales Tax ', p_taxRate);
end;
#
create procedure due( in p_price double
, in p_quantity integer
, in p_discRate double
, in p_taxRate double
, in p_shipping double
, out p_amtDue double
, out p_msg varchar(255) )
begin
declare extPrice double;
declare discAmt double;
declare discPrice double;
declare amtDue double;
declare msg varchar(255);
select p_price, p_quantity, p_discRate, p_taxRate, p_shipping;
set extPrice := p_price * p_quantity;
set discAmt := extPrice * p_discRate;
set discPrice := extPrice - discAmt;
set amtDue:= discPrice * p_taxRate + p_shipping;
set p_amtDue := amtDue;
set msg := call due_form( in amtDue double
, in extPrice double
, in discAmt double
, in discPrice double
, in p_taxRate double
, out p_msg varchar(255) )
set p_msg := msg;
select p_msg;
端;
答案 0 :(得分:0)
您无法将过程的结果分配给变量,但p_msg
将包含返回值,因为前面有out
个关键字。
调用过程时,不得使用in/out
,也不得重复每个参数的类型。该程序已经定义。
select p_price, p_quantity, p_discRate, p_taxRate, p_shipping;
set extPrice := p_price * p_quantity;
set discAmt := extPrice * p_discRate;
set discPrice := extPrice - discAmt;
set amtDue:= discPrice * p_taxRate + p_shipping;
set p_amtDue := amtDue;
call due_form(amtDue, extPrice, discAmt, discPrice, p_taxRate, p_msg );
select p_msg;