急!急!急!请各位SQL-SERVER 2000高手务必过来看一下,高分赠送!!

crystal1129 2002-06-26 05:11:01
1.You are a database developer for Wingtip Toys.You have creeated an order
entry database that includes two tables,as shown below: Users enter orders into the entry application.When a new order is entered, the data is saveed to the Order and LineItem tables in the order entry database.You must ensure that the entire order is saved successfully.
Order
PK OrderID
CustomerID
OrderDate


LineItem
PK temID
OrderID FK_reference order OrderID
ProductID
Price

What should you do?

2.编一个添加学校记录的存储过程。(即做一个插入的存储过程,但也可能用到触发器)
要求:
保证在其他表格中相应的数据也要插入。
(1)城市表(城市编号,城市名,隶属省编号)
(2)学校(学校编号,学校名称,邮政编码,城市编号,学校类别,县、市名)
(3)班级(班级编号,班级名,学校编号,学年)

请会这两题的高手把代码也写上,谢谢!截止日期:6.27
...全文
35 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
bluepower2008 2002-06-27
  • 打赏
  • 举报
回复
嘿嘿
hillhx 2002-06-27
  • 打赏
  • 举报
回复
关键在有没有外键,要先插入父表,再插入子表
另外,在生成各种编号时,如果是程序生成的连续编码,要注意锁表,以免编码生成重复
ba_saner 2002-06-27
  • 打赏
  • 举报
回复
你的两个例子关键就是对数据操作同时成功或同时失败,可以用事务来解决
BEGIN TRANSACTION
操作一
IF @@ERROR <>0
BEGIN
RAISERROR('transaction not completed due to 操作一',16,-1)
ROLLBACK TRANSACTION
END
操作二
IF @@ERROR <>0
BEGIN
RAISERROR('transaction not completed due to 操作二',16,-1)
ROLLBACK TRANSACTION
END
操作三
.
.
.
.

COMMIT TRANSACTION
其中有一个操作不成功,所有完成的操作全部回滚
CDINnet 2002-06-27
  • 打赏
  • 举报
回复
主要就是考虑几个表的约束问题。
crystal1129 2002-06-27
  • 打赏
  • 举报
回复
还是看不懂!
武哥博文 2002-06-27
  • 打赏
  • 举报
回复
请教问题也限定时间??
ba_saner 2002-06-27
  • 打赏
  • 举报
回复
You must ensure that the entire order is saved successfully.
entire - 是关键。
sasacat 2002-06-26
  • 打赏
  • 举报
回复
你把英文翻译一下。。。我懒得看
Yang_ 2002-06-26
  • 打赏
  • 举报
回复
呵呵,我的意思不是太简单,而是太麻烦!!
不好意思,没办法回复了!
愉快的登山者 2002-06-26
  • 打赏
  • 举报
回复
自己思考一下,将问题分解。
crystal1129 2002-06-26
  • 打赏
  • 举报
回复
楼上两位说简单,那为什么不帮忙?
稍微提示一下也可以,不过最好 把代码 也写上,这样我可以看得清楚写,真的好急的!!
ba_saner 2002-06-26
  • 打赏
  • 举报
回复
不是很难的,你这家伙还真懒啊
Yang_ 2002-06-26
  • 打赏
  • 举报
回复
D :)

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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