简体   繁体   English

MySQL:如何调用只有输出参数的存储过程?

[英]MySQL: how to call a stored procedure with only an output parameter?

From my instruction book, I created the following procedure in which the INSERT statement will yield an error:在我的说明书中,我创建了以下过程,其中 INSERT 语句将产生错误:

create procedure f1
(out error char(5))
begin
declare continue handler for SQLSTATE '23000'
set error='23000';
set error ='00000';
insert into teams values(2,27,'derde');
end;

However, it doesn't say how to call this procedure.但是,它没有说明如何调用此过程。 I tried我试过

call f1;

call f1();

call f1(error);

but none of these works.但这些都不起作用。

Thanks!谢谢!

You must change your stored procedure if you want to view the error values as a result.如果您想查看错误值作为结果,您必须更改您的存储过程。 The SP like SP喜欢

**SELECT error**

and Please try to call procedure like并请尝试调用程序

**CALL f1(@error)
SELECT @error**

some_variable = call f1(); some_variable = 调用 f1(); It will work它会工作

Try the following: CALL f1();尝试以下操作: CALL f1(); . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用doctrine 2在symfony 2中使用输出参数调用mysql存储过程? - How to call mysql stored procedure with output parameter in symfony 2 using doctrine 2? 如何在mysql中使用存储过程输出参数? - how to output a parameter using a stored procedure in mysql? 如何使用休眠实体管理器在Spring Boot中使用输出参数调用MySQL存储过程 - How to call MySQL stored procedure with output parameter in spring boot using hibernate entitymanager 如何从ASP.NET中的Mysql存储过程调用输出参数 - How to call an Output Parameter from a Mysql stored procedure in ASP.NET 如何在Google App脚本中使用参数调用MySQL存储过程? - How to call MySQL stored procedure with parameter in Google App Script? 使用ExecuteDataset使用输出参数调用存储过程 - Call stored procedure with an output parameter using ExecuteDataset 如何在Laravel中使用OUT参数调用MySQL存储过程 - How to call MySQL stored procedure with OUT parameter in Laravel 如何在 MySQL 中使用 JSON 参数调用存储过程? - How do I call stored procedure with JSON parameter in MySQL? mysql中存储过程中的EXISTS和输出参数 - EXISTS and output parameter in stored procedure in mysql PHP使用in参数调用mysql存储过程 - PHP Call mysql stored procedure with in parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM