3.sql
来自「数据库的开发事例」· SQL 代码 · 共 27 行
SQL
27 行
create procedure update_date(@x char(40)=null,@y datetime =null)
as
if (@x is null or @y is null)
begin
print '必须同时提供一个产品名称和一个指定日期作为参数'
return 13
end
if not exists(select * from 产品 where 产品名称 = @x)
begin
print '没有指定名称的产品'
return -103
end
if not exists(select * from 产品,订单明细表
where 产品名称=@x and 产品.产品号=订单明细表.产品号)
begin
print '没有满足条件的产品'
return -103
end
update 订购单
set 订购日期=@y
where 订购单.订单号 in
(select 订单明细表.订单号 from 订单明细表
where 订单明细表.产品号 in
(select 产品.产品号 from 产品
where 产品名称= @x)
)
return 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?