当前位置:首页 » 存储配置 » mysql存储过程out参数

mysql存储过程out参数

发布时间: 2022-04-19 20:20:31

A. mysql怎么调用out参数的存储过程

CREATE PROCEDURE [CHARACTER]
@a varchar(20),@b varchar(20),@c varchar(20) output
AS
declare @d int
--begin
select @d=charindex(@a,@b,1)
print @d
if @d=1
begin
set @c='一样'
print @c
end
else
begin
set @c='不同'
print @c
end
GO
在查询分析器中:[CHARACTER] 'Hello','Hello Word!',''

B. mysql存储过程中的 out和in是什么意思呢

out 表示输出的参数,存储过程调用 代码 需要获得此参数值。
in 表示输入参数,默认为in

C. mysql 存储过程

你应该在做统计吧,估计你不会的就是mysql存储过程的语法 我之前也写过 很是郁闷 我给你一段代码 是我用mysql写过的一个存储过程 你看看 主要是了解里面的语法 看懂了 你所说的需求并不难
有看不懂的地方一起讨论 :
begin

declare tikk datetime ;
declare done int default 0;
declare userid int default 0;
declare moleid int default 0;
declare couid int default 0;
declare mname varchar(255) ;
declare opsid int default 0;

declare c1 cursor for Select I_userID,I_operationID from space_operation_record where status<>0 group by I_userID,I_operationID order by createtime desc;
declare continue handler for sqlstate '02000' set done =1;
set tikk = now();
open c1;
repeat
fetch c1 into userid, opsid;
if not done then
select I_moleID from space_operation where status<>0 and ID=opsid into moleid;
if moleid <> '' then
select Nvc_identification from space_operation where status<>0 and ID=opsid into @identiftion;
if moleid > 0 then
Select Nvc_ename from space_mole where status<>0 and ID=moleid into mname;
else
set mname = 'space';
end if;

create temporary table if not exists sp_tab1(id bigint(20),Nvc_content MEDIUMTEXT,I_obyuID bigint(20),I_tID bigint(20),createtime datetime);
INSERT INTO sp_tab1 Select ID,Nvc_content,I_objectID,I_tmID,createtime from space_operation_record where status<>0 and I_operationID=opsid and I_userID=userid ;
select count(*) from sp_tab1 into couid;

set @ihod = 0;
set @listp = '';
set @listpp = '';
set @content0p = '';
set @content0 = '';
while couid > 0 do
select ID,Nvc_content,I_obyuID,createtime,I_tID into @iok,@conuiy,@objiplk,@crtimhr,@tmids from sp_tab1 where ID > @ihod order by ID asc limit 0,1;
if @iok <> '' then
if mname = 'blog' then
INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,createtime) VALUES (@iok,userid,@conuiy,@crtimhr,tikk);
elseif mname = 'team' then
if(@identiftion = 'addblog' || @identiftion = 'mdyblog') then
INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,I_tmID,createtime) VALUES (@iok,userid,@conuiy,@crtimhr,@tmids,tikk);
else
set @listpp = CONCAT(@listpp,CONCAT(@objiplk,','));
set @operarry1p = substring_index(@conuiy,'|',1);
set @operarry2p = substring_index(@conuiy,'|',-1);
set @content0p = CONCAT(@content0p,CONCAT(@operarry2p,SPACE(1)));
set @objlistp = substring(@listpp,1,length(@listpp)-1);
end if;
elseif mname = 'space' then
if(@identiftion = 'headphoto' || @identiftion = 'status') then
INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,I_tmID,createtime) VALUES (@iok,userid,@conuiy,@crtimhr,@tmids,tikk);
else
set @listppr = CONCAT(@listppr,CONCAT(@objiplk,','));
set @operarry1pr = substring_index(@conuiy,'|',1);
set @operarry2pr = substring_index(@conuiy,'|',-1);
set @content0pr = CONCAT(@content0pr,CONCAT(@operarry2pr,SPACE(1)));
set @objlistpr = substring(@listppr,1,length(@listppr)-1);
end if;
else
set @listp = CONCAT(@listp,CONCAT(@objiplk,','));
set @operarry1 = substring_index(@conuiy,'|',1);
set @operarry2 = substring_index(@conuiy,'|',-1);
set @content0 = CONCAT(@content0,CONCAT(@operarry2,SPACE(1)));
set @objlist = substring(@listp,1,length(@listp)-1);
end if;
set @ihod = @iok;
end if;
set couid = couid -1;
end while;

if @content0 <> '' then
set @contentp = CONCAT(@operarry1,concat('|',@content0));
Select createtime,ID into @uitimej,@IDjok from space_operation_record where status<>0 and I_operationID=opsid order by createtime desc limit 0,1;
if @uitimej <> '' then
INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,createtime,Nvc_objlist) VALUES(@iok,userid,@contentp,@crtimhr,tikk,@objlist);
end if;
end if;
if @content0p <> '' then
if @identiftion = 'addphoto' then
set @contentp = CONCAT(@operarry1p,CONCAT('|',@content0p));
else
set @contentp = CONCAT(@operarry1p,CONCAT(@content0p,'|'));
end if;

Select createtime,ID into @uitimej,@IDjok from space_operation_record where status<>0 and I_operationID=opsid order by createtime desc limit 0,1;
if @uitimej <> '' then
INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,createtime,Nvc_objlist,I_tmID) VALUES(@iok,userid,@contentp,@crtimhr,tikk,@objlistp,@tmids);
end if;
end if;
if @content0pr <> '' then
set @contentp = CONCAT(@operarry1p,concat('|',@content0pr));
Select createtime,ID into @uitimej,@IDjok from space_operation_record where status<>0 and I_operationID=opsid order by createtime desc limit 0,1;
if @uitimej <> '' then
INSERT INTO space_operation_stat(I_operationID,I_userID,Nvc_content,D_stattime,createtime,Nvc_objlist,I_tmID) VALUES(@iok,userid,@contentp,@crtimhr,tikk,@objlistp,@tmids);
end if;
end if;
delete from sp_tab1;
end if;
end if;

until done end repeat;
close c1;
drop temporary table if exists sp_tab1 ;

UPDATE space_operation_play SET status=0;
UPDATE space_operation_display SET status=0;
Select createtime into @ptimes from space_operation_stat where status<>0 order by createtime desc limit 0,1;
if @ptimes <>'' then
create temporary table if not exists sp_tab2(id bigint(20),Nvc_content MEDIUMTEXT,I_userID bigint(20),I_lyuID bigint(20),D_stattime datetime);
INSERT INTO sp_tab2 Select ID,Nvc_content,I_userID,I_tmID,D_stattime from space_operation_stat where status<>0 and createtime=@ptimes order by D_stattime desc limit 0,30;
select count(*) from sp_tab2 into @cou1id;
set @uoj = 0;
while @cou1id > 0 do
select ID,Nvc_content,I_userID,D_stattime,I_lyuID into @io1k,@conui1y,@objipl1k,@crtimh1r,@unlpa from sp_tab2 where ID > @uoj order by ID asc limit 0,1;
if @io1k <> '' then
INSERT INTO space_operation_play(I_statID,Nvc_content,D_stattime,I_userID,Createtime,I_tmID) VALUES (@io1k,@conui1y,@crtimh1r,@objipl1k,now(),@unlpa);
set @uoj = @io1k;
end if;
set @cou1id = @cou1id -1;
end while;
drop temporary table if exists sp_tab2 ;
end if;

end

D. mysql怎么调用out参数的存储过程

call sp_add();
是不是你定义的过程有问题吧,并没有指出返回结果来
像我这样是可以的:

CREATE PROCEDURE sp_add(a int, b int,out c int)
begin

set c=a+ b;

end;
调用过程:
call sp_add (1,2,@a);
select @a;

E. mysql怎么创建和调用out参数的存储过程

call sp_add(); 是不是你定义的过程有问题吧,并没有指出返回结果来 像我这样是可以的: CREATE PROCEDURE sp_add(a int, b int,out c int) begin set c=a+ b; end; 调用过程: call sp_add (1,2,@a); select @a;

F. mysql存储过程怎么接收返回参数

mysql中要获得存储过程的返回值,可以增加一个out参数,用来返回。
mysql中存储过程的例子:
CREATE PROCEDURE addvoucher (
IN userid INT,
IN voucherid INT,
OUT result INT
)
BEGIN
SELECT
@endate_a := endate ,@batch_a := batch ,@c_count_a := c_count,
@isdead_a := isdead
FROM
t_voucher
WHERE
id = voucherid;

SET autocommit = 0;
IF EXISTS (
SELECT
*
FROM
t_user_voucher tuv,
t_voucher tv
WHERE
tv.id = tuv.voucherid
AND tv.batch =@batch_a
) THEN

SET result = 1;-- 已存在

SELECT
result;

ELSE

IF @c_count_a > 0 THEN

IF (
TO_DAYS(@endate_a) - TO_DAYS(NOW())
) > 0 THEN

G. C# 怎么调Mysql带inout参数的存储过程

string MyConString = "..."
OdbcConnection conn = new OdbcConnection(MyConString);

conn.Open();
OdbcCommand cmd = new OdbcCommand();
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcere;
cmd.CommandText = "p_test";
OdbcParameter p1 = new OdbcParameter("t_count", OdbcType.Int);
p1.Direction = ParameterDirection.Output;
cmd.Parameters.Add(p1);

int i = cmd.ExecuteNonQuery();
TextBox1.Text = p1.Value.ToString();

conn.Close();

热点内容
汉诺塔递归算法python 发布:2024-11-19 18:26:17 浏览:578
盲井ftp 发布:2024-11-19 18:21:38 浏览:264
悦虎二代安卓如何看电量 发布:2024-11-19 18:19:27 浏览:295
人工驾驶编程 发布:2024-11-19 18:05:20 浏览:271
java编程试题 发布:2024-11-19 17:26:37 浏览:664
python显示二进制文件 发布:2024-11-19 17:26:36 浏览:147
excel中编程 发布:2024-11-19 17:23:32 浏览:549
android透明图片 发布:2024-11-19 17:01:50 浏览:163
iis上传文件限制 发布:2024-11-19 16:37:55 浏览:409
面试题算法 发布:2024-11-19 16:30:25 浏览:548