0

我正在尝试创建一个程序来计算一些利率价格等。这里有一点摘录。

但是,我收到一条错误消息:检查 'call due_form( in amtDue double, in 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;

结尾;

4

1 回答 1

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;
于 2012-09-13T00:02:08.993 回答