早教吧 育儿知识 作业答案 考试题库 百科 知识分享

这个存储过程是什么意思setANSINULLSONsetQUOTEDIDENTIFIERONGOALTERProc[dbo].[ProcGSF](@GoodsIDbigint,@ShipWayvarchar(50))asifexists(selectShipFeefromtbShipTypewhereshipWay=@shipWayandClassID=(selectClassIDfr

题目详情
这个存储过程是什么意思set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO ALTER Proc [dbo].[Proc_GSF] ( @GoodsID bigint, @ShipWay varchar(50) ) as if exists(select ShipFee from tb_ShipType where shipWay=@shipWay and ClassID= ( select ClassID from tb_GoodsInfo where GoodsID=@GoodsID ) ) begin select ShipFee from tb_ShipType where shipWay=@shipWay and ClassID= ( select ClassID from tb_GoodsInfo where GoodsID=@GoodsID ) end else return 100
▼优质解答
答案和解析
-- ============================================== -- 前面是判断是否有符合条件的ShipFee值,后面是显示符合条件的ShipFee值 -- ============================================== if exists(select ShipFee /*判断tb_ShipType表中是否存在ShipFee这个字段*/ from tb_ShipType where shipWay=@shipWay and /* ShipFee这个字段满足条件的是:表中shipWay值等于输入的@shipWay 以及 ClassID值等于tb_GoodsInfo表中的ClassID */ ClassID= ( select ClassID from tb_GoodsInfo /*根据输入的@GoodsID从tb_GoodsInfo标红获取到的ClassID*/ where GoodsID=@GoodsID ) ) begin -----如果存在,则执行下面代码,即显示ShipFee值 select ShipFee from tb_ShipType where shipWay=@shipWay and ClassID= ( select ClassIDfrom tb_GoodsInfo where GoodsID=@GoodsID ) end else ----如果不存在,则返回值100 return 100 不懂的再call me, 从前面看,说明这个存储过程已经存在了,这是修改这个存储过程.