主题:[原创]如何在存储过程中加条件
原存储过程语句如下:
CREATE PROCEDURE dbo.UPDATEXMATNAM
(
@cusmat nvarchar(3),
@matcode nvarchar(9),
@matval nvarchar(10),
@matno nvarchar(10),
@matnmc nvarchar(50),
@matengc nvarchar(50),
@matcnm nvarchar(50),
@matspcon nvarchar(50),
@matspctw nvarchar(50),
@matspcth nvarchar(50),
@colrno nvarchar(10),
@colrnm nvarchar(10),
@matun nvarchar(4),
@wegun real,
@supno nvarchar(3),
@supnm nvarchar(10),
@matprc real,
@moneynm varchar(8),
@ovrat real,
@ackey bit,
@matuni nvarchar(4),
@edittime datetime,
@user nvarchar(30)
)
AS
update MATNAM set mat_no=@matno,mat_nm=@matnmc,mat_eng=@matengc,MAT_CNM=@matcnm,mat_spc=@matspcon,mat_spc_tw=@matspctw,mat_spc_th=@matspcth,
colr_no=@colrno,colr_nm=@colrnm,mat_un=@matun,weg_un=@wegun,sup_no=@supno,sup_nm=@supnm,mat_prc=@matprc,ov_rat=@ovrat,ac_key=@ackey,mat_uni=@matuni,edit_time=@edittime,[user]=@user ,MONEY_NM=@moneynm where cus_mat=@cusmat and mat_code=@matcode and mat_val=@matval
RETURN
GO
现在我想对mat_prc=@matprc进行条件限制,即:当材料单价MAT_PRC小于原来的单价时则允许修改,当大于时则提供密码输入,密码正确则允许修改。请问:如果在存储过程里面修改的话要怎么写呢?请高手帮忙解答,谢谢
CREATE PROCEDURE dbo.UPDATEXMATNAM
(
@cusmat nvarchar(3),
@matcode nvarchar(9),
@matval nvarchar(10),
@matno nvarchar(10),
@matnmc nvarchar(50),
@matengc nvarchar(50),
@matcnm nvarchar(50),
@matspcon nvarchar(50),
@matspctw nvarchar(50),
@matspcth nvarchar(50),
@colrno nvarchar(10),
@colrnm nvarchar(10),
@matun nvarchar(4),
@wegun real,
@supno nvarchar(3),
@supnm nvarchar(10),
@matprc real,
@moneynm varchar(8),
@ovrat real,
@ackey bit,
@matuni nvarchar(4),
@edittime datetime,
@user nvarchar(30)
)
AS
update MATNAM set mat_no=@matno,mat_nm=@matnmc,mat_eng=@matengc,MAT_CNM=@matcnm,mat_spc=@matspcon,mat_spc_tw=@matspctw,mat_spc_th=@matspcth,
colr_no=@colrno,colr_nm=@colrnm,mat_un=@matun,weg_un=@wegun,sup_no=@supno,sup_nm=@supnm,mat_prc=@matprc,ov_rat=@ovrat,ac_key=@ackey,mat_uni=@matuni,edit_time=@edittime,[user]=@user ,MONEY_NM=@moneynm where cus_mat=@cusmat and mat_code=@matcode and mat_val=@matval
RETURN
GO
现在我想对mat_prc=@matprc进行条件限制,即:当材料单价MAT_PRC小于原来的单价时则允许修改,当大于时则提供密码输入,密码正确则允许修改。请问:如果在存储过程里面修改的话要怎么写呢?请高手帮忙解答,谢谢