MySQL语句的转化

Summerle 2012-12-26 06:11:37

--查询所有顾客信息-------------------
create procedure getAllCustomer
begin
select * from Customer;
end

--改变商品的数量---------------------
create proc changeGoodsQuantity
(GoodsID1 varchar(10),quantity int)
begin
declare number int;
set number=(select count(*) from Goods where goodsID=GoodsID1)
update Goods set GoodsQuantity=(number-quantity) where GoodsID=GoodsID1
end
--把购物车中的信息导入到订单中,并且删除购物车信息--------
create proc createForm
(customerID int,totalPrice float)
begin
declare orderID varchar(40)
set orderID=(select carID from ShoppingCar where customerID=customerID)
insert into OrderForm values (orderID,customerID,getdate(),totalPrice)
insert into OrderFormDetails select * from ShoppingCarDetails where carID=orderID

delete from ShoppingCarDetails where carID=orderID
delete from ShoppingCar where carID=orderID
end

从SQLserver转换成MysqL,这三个创建储存过程怎么也不对,应该如何改~
...全文
145 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2013-01-02
  • 打赏
  • 举报
回复
delimiter // create procedure getAllCustomer () begin select * from Customer; end// 你的()都哪儿去了? 类似语法问题建议看一下MYSQL的官方免费手册。
Summerle 2013-01-02
  • 打赏
  • 举报
回复
[SQL] create procedure getAllCustomer begin select * from Customer; end [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'begin select * from Customer; end' at line 2 ------------------------------------------------------- [SQL] create proc changeGoodsQuantity (GoodsID1 varchar(10),quantity int) begin declare number int; [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'proc changeGoodsQuantity (GoodsID1 varchar(10),quantity int) begin declare ' at line 1 --------------------------------------- [SQL] create proc createForm (customerID int,totalPrice float) begin declare orderID varchar(40) set orderID=(select carID from ShoppingCar where customerID=customerID) insert into OrderForm values (orderID,customerID,getdate(),totalPrice) insert into OrderFormDetails select * from ShoppingCarDetails where carID=orderID delete from ShoppingCarDetails where carID=orderID delete from ShoppingCar where carID=orderID end [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'proc createForm (customerID int,totalPrice float) begin declare orderID va' at line 1 --------------------------------------- 3个所有的错误。。
ACMAIN_CHM 2012-12-26
  • 打赏
  • 举报
回复
delimiter // create procedure getAllCustomer begin select * from Customer; end//
ACMAIN_CHM 2012-12-26
  • 打赏
  • 举报
回复
错误信息是什么? MYSQL的错误提示是什么?贴出以供分析。

56,677

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧