当前位置:首页 » 存储配置 » 带参数的存储过程

带参数的存储过程

发布时间: 2022-01-15 05:14:12

1. 执行带参数的存储过程

1、
对象资源管理器
中选中你要执行的存储过程
2、右击选择
对话框中的执行存储过程...
3、在出现的对话框中填入你参数的值
点击确定

2. 带参数的存储过程如何去写谁给举个例子

写带有参数存储过程应该是sql数据库的问题:
先建立一个表,并添加一些数据来进行演示:
create
table
t_student(
id
int
not
null,
name
nvarchar
(10)
null,
age
tinyint
null,
school
nvarchar(20)
null,
class
nvarchar(10)
null,
score
float
null,
constraint
[pk_student_id]
primary
key
clustered(id)
)
go
insert
into
t_student
values(1,'张小红',8,'育才小学','一班',92)
insert
into
t_student
values(2,'王丽丽',8,'育才小学','一班',90)
insert
into
t_student
values(3,'张燕',7,'云华小学','二班',86)
insert
into
t_student
values(4,'刘华',6,'云华小学','二班',85)
一、exec
exec命令可以执行一个存储过程也可以执行一个动态sql语句。先来看看怎么执行存储过程:
新建一个存储过程
sp_getstudent
,返回
成绩大于90
分的学生:
create
procere
[dbo].[sp_getstudent]
@score
float,
@nums
int
output
as
begin
set
nocount
on;
select
*
from
t_student
where
score
>=@score
select
@nums=count(1)
from
t_student
where
score
>=@score
if(@nums>0)
return
1
else
return
0
end
go
该存储过程涉及了
查询操作、返回值和输出参数,我们来看用exec
命令如何调用:
declare
@return_value
int,
@outnums
int
exec
@return_value
=
[dbo].[sp_getstudent]
@score
=
90,
@nums
=
@outnums
output
select
@outnums
as
n'大于90分的人数'
select
'返回值'
=
@return_value
go
执行结果:
我们发现exec
执行存储过程和我们平时程序执行一个方法是几乎一样的,返回值参数
直接就可以等于存储过程的执行后的返回值,输出参数
在后面需要增加
output
关键字。

3. sql数据库中怎样调用带参数的存储过程

在sql server中 执行带参数的存储过程
exec+空格+存储过程名+空格+参数
多个参数的话用逗号分隔 传出参数要加output
例如:
exec P_GetIntegratedFluxOneMoment @StartTableName,@ColName,@StartTime,@StartValue output
其中@StartTableName,@ColName,@StartTime,@StartValue都是前面已经定义好的变量 传入参数也可以不用变量 直接写值也行

程序中调用的话看你用什么语言了 各个语言的调用方法不一样

4. oracle 中用什么命令执行一个带参数的存储过程

具体如下:

1、第一步,创建一个新的存储过程,见下图,转到下面的步骤。

5. oracle带输入参数的存储过程

createorreplaceproceresp_test(iv_yinvarchar2,iv_minvarchar2)
as
v_countinteger;
begin
selectcount(*)intov_countfromtable_testwhereyear=iv_yandmonth=iv_m;
ifv_count>0then
Raise_Application_Error(-20001,'数据已存在!');
else
insertintotable_testvalues(iv_y,iv_m);
commit;
endif;
end;

6. SQL一个带参数的存储过程写法

你的这个做法没有意义,一般存储过程主要是针对sql语句执行效率低和数据完整性等来说的,你用这种方法就单单为了查询一个表中的TOP信息,这样与存储过程的有点恰恰相反,因为这个方法实现存储过程中取出你所要的信息,同是也能用同样的方法更简便的从表中取出你要的信息

7. 带参数的存储过程!!!!!!!

你已经将 @name,@pwd 定义为varchar(100)了,所以在
select count(*) from users where name='@name' and password='@pwd'
这里的'@name'和'@pwd'就不用加引号了,否则你执行
exec userCheck 'aaa','aaa' 时,你的查询语句实际是
select count(*) from users where name= ''aaa'' and password= ''aaa'',
这样肯定没有这个数据了,返回是0

8. 存储过程:带参数类型有哪些

有in,out,inout
in:表示参数从外部传入到里面使用(过程内部使用),可以是直接数据也可以是保存数据的变量
out:表示参数是从过程里面吧数据保存到变量中,交给外部使用,传入的必须的变量
inout:数据可以从外部传入到过程内部使用,同时内部操作之后,又会将数据返还给外部

9. oracle带参(传入,传出)的存储过程怎么执行

1、新建存储过程,Create or ReplaceProcere CHK_SYS_EMP 检查系统工号。

热点内容
访问拦截怎么解除安卓 发布:2024-09-20 17:28:48 浏览:273
萝卜干存储 发布:2024-09-20 17:21:37 浏览:714
苹果手机如何迁移软件到安卓手机 发布:2024-09-20 17:21:34 浏览:691
查看服务器ip限制 发布:2024-09-20 16:56:27 浏览:388
p搜系统只缓存1页为什么 发布:2024-09-20 16:48:51 浏览:838
上网的账号和密码是什么东西 发布:2024-09-20 16:31:31 浏览:612
安卓手机王者荣耀如何调超高视距 发布:2024-09-20 16:31:30 浏览:428
安卓G是什么app 发布:2024-09-20 16:23:09 浏览:81
iphone怎么压缩文件 发布:2024-09-20 16:08:18 浏览:356
linux查看用户名密码是什么 发布:2024-09-20 16:03:20 浏览:744