如何判断存储过程变量的值是否为空?
如何判断存储过程变量的值是否为空?主要判断员工的字段输入值是否为空,我在另外一个表CMSFIE里定义了哪些字段可以为空哪些字段不能为空,然后在员工资料的保存中取这个字段的值来和CMSFIE中存储的是否为空标志进行比对;
模拟过程如下:
create proc myepatest
@EPA002 varchar(10), --员工信息字段
@EPA003 varchar(80), --员工信息字段
@EPA004 varchar(40) --员工信息字段
as
declare @R varchar(1000)
declare @fieldname varchar(10) --CMSFIE表中存储的字段名
declare @nsql nvarchar(1000)
declare mycursor cursor for
select (substring(FIE003,1,6)) Field from CMSFIE where FIE002='vCMSEPA' and FIE019='1' //从CMSFIE表中读出必填字段名
open mycursor
fetch next from mycursor into @fieldname
while (@@FETCH_STATUS=0)
begin
set @nsql='if (@'+@fieldname+'='''') or (@'+@fieldname+' is null) set @R=''x'' else set @R= ''y'' '
EXEC(@nSQL)
fetch next from mycursor into @fieldname
end
close mycursor
deallocate mycursor
---执行时报错 @EPA002,@EPA003 ,@R变量没有定义
该如何定义
模拟过程如下:
create proc myepatest
@EPA002 varchar(10), --员工信息字段
@EPA003 varchar(80), --员工信息字段
@EPA004 varchar(40) --员工信息字段
as
declare @R varchar(1000)
declare @fieldname varchar(10) --CMSFIE表中存储的字段名
declare @nsql nvarchar(1000)
declare mycursor cursor for
select (substring(FIE003,1,6)) Field from CMSFIE where FIE002='vCMSEPA' and FIE019='1' //从CMSFIE表中读出必填字段名
open mycursor
fetch next from mycursor into @fieldname
while (@@FETCH_STATUS=0)
begin
set @nsql='if (@'+@fieldname+'='''') or (@'+@fieldname+' is null) set @R=''x'' else set @R= ''y'' '
EXEC(@nSQL)
fetch next from mycursor into @fieldname
end
close mycursor
deallocate mycursor
---执行时报错 @EPA002,@EPA003 ,@R变量没有定义
该如何定义
...全文
相关推荐
JS判断变量是否为空判断是否null
本节主要介绍了JS判断变量是否为空是否null的方法,需要的朋友可以参考下
js 判断是否为空
js 判断是否为空
SQLSERVER ISNULL 函数与判断值是否为空的sql语句
由于服务器设置不当导致sqlserver的某个字段为空,导致部分内容显示失败,所有这里需要将为空的字符替换为制定的字符
shell判断一个变量是否为空方法总结
在本篇文章里小编给大家分享了关于shell判断一个变量是否为空方法总结内容,有兴趣的朋友们学习下。
Shell脚本中判断输入变量或者参数是否为空的方法
先给大家分享一篇关于shell判断一个变量是否为空方法总结内容 shell判断一个变量是否为空方法总结 https://www.jb51.net/article/154835.htm 1.判断变量 代码如下: read -p “input a word :” word if [ ! -n “$word” ] ;then echo “you have not input a word!” else echo “the word you input is $word” fi 2.判断输入参数 代码如下: #!/bin/bash if [ ! -n “$1” ] ;then


疑难问题
