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,这三个创建储存过程怎么也不对,应该如何改~
...全文
184 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的错误提示是什么?贴出以供分析。
代码下载链接: https://pan.quark.cn/s/a4b39357ea24 第 一 章 概述 1-1 简述计算机程序设计语言的发展阶段。 解: 自从计算机诞生以来,程序设计语言经历了从机器语言、汇编语言到高级语言的演变过程,C++语言作为一种面向对象的编程语言,也属于高级语言范畴。 1-2 面向对象的编程语言具备哪些特性? 解: 面向对象的编程语言与传统的编程语言有着本质的区别,其设计初衷是为了更直观地模拟现实世界中存在的事物及其相互关系。这类编程语言将客观事物视为具有属性和行为的对象,通过抽象方法提取出同一类对象的共同属性(静态特征)和行为(动态特征),从而构建类。借助类的继承与多态机制,能够便捷地实现代码复用,显著缩短软件开发周期,并确保软件风格的一致性。因此,面向对象的编程语言使得程序能够较为准确地反映问题域的本质,软件开发人员可以运用人类惯用的思维模式进行开发工作。C++语言是目前应用最为广泛的面向对象编程语言。 1-3 结构化程序设计方法是什么?这种方法有哪些优势和不足? 解: 结构化程序设计的核心思想是自顶向下、逐步求精;其程序结构按照功能划分为多个基本模块;各模块之间的关联尽可能简化,在功能上保持相对独立性;每个模块内部均由顺序、选择和循环三种基本结构构成;模块化实现的具体途径是利用子程序。结构化程序设计由于采用模块分解与功能抽象,自顶向下、分而治之的策略,从而有效地将一个较为复杂的程序系统设计任务分解成许多易于管理和处理的子任务,便于开发与维护。 尽管结构化程序设计方法具备诸多优点,但它本质上仍是一种面向过程的程序设计方法,将数据与处理数据的操作分离为相互独立的实体。当数据结构发生变化时,所有相关的处理过程都需要进行相应的调整,每一种...

57,064

社区成员

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

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