无法创建过程phpMyAdmin MYSQL错误

无法创建过程phpMyAdmin MYSQL错误,mysql,sql,stored-procedures,mariadb,Mysql,Sql,Stored Procedures,Mariadb,救命!!我卡住了,我不知道怎么了。 我正在开发MySql,但它不会创建过程,我没有主意了 CREATE PROCEDURE sc_new_ord(IN inscid INT, IN incust_id INT, IN indeltype_id INT, IN duty_it INT, IN delcost INT, OUT ttmount INT, OUT outordid INT) BEGIN DECLARE ord_id INT; DECLARE total INT; IN

救命!!我卡住了,我不知道怎么了。 我正在开发MySql,但它不会创建过程,我没有主意了

CREATE PROCEDURE sc_new_ord(IN inscid INT, IN incust_id INT, IN indeltype_id INT, IN duty_it INT, IN delcost INT, OUT ttmount INT, OUT outordid INT)
BEGIN
  DECLARE ord_id INT;
  DECLARE total INT;
  
  INSERT INTO tbl_orders (customer_id, ship_type_id, rate_id, status) VALUES
         (incust_id, indeltype_id, duty_it,0);
  
  SELECT LAST_INSERT_ID() INTO inscid;

  INSERT INTO tbl_ord_det (ord_id,inv_id, item, qtty, price)
  SELECT ord_id, tbl_inventory.Inv_id, tbl_inventory.Item, tbl_shp_ct.qtty,
              COALESCE(NULLIF(tbl_inventory.Offer_Price, 0), tbl_inventory.Price) AS price
  FROM        tbl_shp_ct
  INNER JOIN  tbl_inventory
                ON tbl_shp_ct.inv_id = tbl_inventory.Inv_id
  WHERE tbl_shp_ct.sc_id = inscid AND tbl_shp_ct.buy_now;
    -- total amount
  UPDATE tbl_orders
  SET    tt_mnt = (SELECT SUM(price * qtty)FROM tbl_ord_det WHERE ord_id = ord_id)
  WHERE  ord_id = ord_id;
  CALL sc_empty (inscid);
  SELECT (SUM(price * qtty) FROM tbl_ord_det WHERE  ord_id = ord_id) as tt INTO total;
  SELECT total, delcost, (total+delcost) INTO ttmount;
  SELECT ord_id INTO outordid;
END
完整错误:MySQL说:文档


1064-您的SQL语法有错误;如果您使用的是mysql数据库,请查看与您的MariaDB服务器版本相对应的手册,以获取第3行附近要使用的正确语法,然后按照下面的说明进行尝试,如果仍然使用mysql数据库,请共享错误-

DELIMITER $$
CREATE PROCEDURE sc_new_ord(IN inscid INT, IN incust_id INT, IN indeltype_id INT, IN duty_it INT, IN delcost INT, OUT ttmount INT, OUT outordid INT)
BEGIN
  DECLARE ord_id INT;
  DECLARE total INT;

  INSERT INTO tbl_orders (customer_id, ship_type_id, rate_id, status) VALUES
         (incust_id, indeltype_id, duty_it,0);

  SELECT LAST_INSERT_ID() INTO inscid;

  INSERT INTO tbl_ord_det (ord_id,inv_id, item, qtty, price)
  SELECT ord_id, tbl_inventory.Inv_id, tbl_inventory.Item, tbl_shp_ct.qtty,
              COALESCE(NULLIF(tbl_inventory.Offer_Price, 0), tbl_inventory.Price) AS price
  FROM        tbl_shp_ct
  INNER JOIN  tbl_inventory
                ON tbl_shp_ct.inv_id = tbl_inventory.Inv_id
  WHERE tbl_shp_ct.sc_id = inscid AND tbl_shp_ct.buy_now;
    -- total amount
  UPDATE tbl_orders
  SET    tt_mnt = (SELECT SUM(price * qtty)FROM tbl_ord_det WHERE ord_id = ord_id)
  WHERE  ord_id = ord_id;
  CALL sc_empty (inscid);
  SELECT (SUM(price * qtty) FROM tbl_ord_det WHERE  ord_id = ord_id) as tt INTO total;
  SELECT total, delcost, (total+delcost) INTO ttmount;
  SELECT ord_id INTO outordid;
END$$
DELIMITER ;
改变

作为tt移动到正确的位置


为什么在过程1064中使用和标记-您的SQL语法有错误;检查与您的MariaDB服务器版本对应的手册,了解正确的语法。和是一个错误,对不起,你是在使用mysql还是mariadb?我正在使用PHPMYADMINW,为什么你要将id插入这个SELECT LAST_INSERT_id到inscid中;由于inscid是过程函数的输入参数?上述错误:1064-您的SQL语法有错误;检查与您的MariaDB服务器版本相对应的手册,以了解使用near“FROM tbl_ord_det,其中ord_id=ord_id as tt to total的正确语法;在第22行选择total,delc'可以让我知道这里的第二个ord_id是什么吗,其中ord_id=ord_id,因为我没有在代码中得到任何变量。第二个ord_id是表tbl_orders中的键,它是tbl_order det中的外键从tbl_order det中选择SUMprice*qtty,其中ord_id=ord_id作为tt进入total;不清楚你想在这里做什么..这不是一个有效的查询…尝试在mysql提示符下执行它,并检查它是否给你结果。
SELECT (SUM(price * qtty) FROM tbl_ord_det WHERE  ord_id = ord_id) as tt INTO total;
SELECT SUM(price * qtty) as tt FROM tbl_ord_det WHERE  ord_id = ord_id INTO total;