gpt4 book ai didi

MySQL dbCursor 不工作

转载 作者:行者123 更新时间:2023-11-29 22:35:59 26 4
gpt4 key购买 nike

这是我的代码。我正在尝试将购物车商品移至订单商品表中。它不工作可能是什么问题?

CREATE  PROCEDURE `insert_order_details`
(IN `customer_id` VARCHAR(255),
IN `order_id` VARCHAR(255),
IN `shipping_country` VARCHAR(255),
IN `shipping_state` VARCHAR(255),
IN `shipping_address` VARCHAR(255))
BEGIN

DECLARE v_finished INTEGER DEFAULT 0;
DECLARE product_id varchar(255);
DECLARE quantity integer;
DECLARE unit_price integer;

Declare cart_cursor CURSOR
FOR select @order_id, product_id , quantity, unit_price, userID
from cart where userID=@customer_id and status = 'PENDING';

DECLARE CONTINUE HANDLER FOR NOT FOUND SET v_finished = 1;
OPEN cart_cursor;

read_loop: LOOP
FETCH cart_cursor INTO order_id, product_id, quantity, unit_price, customer_id;

IF v_finished = 1 THEN
LEAVE read_loop;
END IF;
INSERT INTO order_details
(order_id,product_id, quantity, unit_price,
customer_id,shipping_country,shippping_state, shipping_address)
VALUES
(@order_id,product_id, quantity, unit_price, @customer_id,
date_added,@shipping_country,@shipping_state,@shipping_address) ;

END LOOP read_loop;

CLOSE cart_cursor;
END

最佳答案

您在光标中引用了用户变量@order_id,而实际上您想使用存储过程变量order_id。

关于MySQL dbCursor 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29549763/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com