2

我想做这样的事情:

Quantity   Price    Payment
1           12      12.00

这是我的代码:

CREATE DEFINER=`root`@`localhost` 
PROCEDURE `insertproducts`
(
    pname varchar(50), 
    pdesc varchar(50),
    psupp varchar(50),
    pdate date,
    pquant int,
    pprice double
)
begin
insert into products
(
    prodname,
    proddescription,
    prodsupplier,
    proddate,
    prodquantity,
    prodprice,
    prodpayment
) 
values 
(
    pname,
    pdesc,
    psupp,
    pdate,
    pquant,
    pprice,
    ppayment
) 
set prodpayment = pprice * prodquantity;
end

这不起作用,有什么想法吗?

4

1 回答 1

3

什么是ppayment?可以直接将参数相乘,

insert into products
(
    prodname, 
    proddescription, 
    prodsupplier, 
    proddate, 
    prodquantity, 
    prodprice, 
    prodpayment
) 
values 
(
    pname, 
    pdesc, 
    psupp, 
    pdate, 
    pquant, 
    pprice, 
    pprice*prodquantity
)
于 2013-03-24T08:58:57.423 回答