我觉得自己像个菜鸟一样问这个问题,但是我怎么也想不出这个问题。我正在尝试在这里创建一个存储过程:
create or replace procedure add_cart(@user_id int, @product_id int, @quantity int)
begin
declare cart_id int;
start transaction;
select id into cart_id from carts where user_id = @user_id;
if cart_id is null then
insert into carts (user_id, updated_at, inserted_at) values (@user_id, now(), now());
select id into cart_id from carts where user_id = @user_id;
end if;
insert into cart_products (cart_id, product_id, quantity) values (cart_id, @product_id, @quantity);
commit;
end
但我一直收到这个消息:
[2022-06-14 10:29:29] [42000][1064] (conn=12) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@user_id int, @product_id int, @quantity int)
[2022-06-14 10:29:29] [42000][1064] You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '@user_id int, @product_id int, @quantity int)
[2022-06-14 10:29:29] begin
[2022-06-14 10:29:29] declare cart_id int;
[2022-06-14 10:29:29] ...' at line 1
MariaDB版本10.6.0
,如果这是相关的。谢谢:)
1条答案
按热度按时间2g32fytz1#
Nvm,明白了。是
@
标志:)