如何从存储过程中获取消息

如何从存储过程中获取消息

本文介绍了如何从存储过程中获取消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ALTER程序[dbo]。[GetSubmitDetails]



@cust_id int,

@name varchar(50),

@state Varchar(50),

@s_amount varchar(50),

@sales_id int,

@select out







AS

声明@count int

设置@count =(SELECT count(*)FROM customer inner join

sales

on customer.cust_id = sales.cust_id

WHERE customer.cust_id = @cust_id

和sales.sales_id=@sales_id)

if(@ count> 0)

BEGIN



SELECT'此记录已存在!'

结束

ELSE



BEGIN





选择'加入记录'

插入test.dbo 。[customer](cust_id,name,[state])值(@ cust_id,@ name,@ state)



插入test.dbo。[sales]( cust_id,sales_id,s_amount)值(@ cust_id,@ sales_id,@ s_amount)

END

解决方案

ALTER procedure [dbo].[GetSubmitDetails]
(
@cust_id int ,
@name varchar (50),
@state Varchar (50),
@s_amount varchar (50),
@sales_id int,
@select out

)

AS
declare @count int
set @count = (SELECT count(*) FROM customer inner join
sales
on customer.cust_id=sales.cust_id
WHERE customer.cust_id = @cust_id
and sales.sales_id=@sales_id)
if(@count>0)
BEGIN

SELECT 'This record already exists!'
END
ELSE

BEGIN


SELECT 'Record Added'
Insert into test.dbo.[customer](cust_id,name,[state]) values (@cust_id,@name,@state)

Insert into test.dbo.[sales](cust_id,sales_id,s_amount) values (@cust_id,@sales_id,@s_amount)
END

解决方案


这篇关于如何从存储过程中获取消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 22:35