Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从过程中的第二个select语句返回结果集?_Java_Mysql_Stored Procedures - Fatal编程技术网

Java 如何从过程中的第二个select语句返回结果集?

Java 如何从过程中的第二个select语句返回结果集?,java,mysql,stored-procedures,Java,Mysql,Stored Procedures,如何从第二条select语句返回结果集 我有样品: -- -------------------------------------------------------------------------------- -- Routine DDL -- Note: comments before and after the routine body will not be stored by the server -- -------------------------------------

如何从第二条select语句返回结果集

我有样品:

-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `getGender20`(in id INT)
BEGIN
 DECLARE str VARCHAR(50);
  select @str :=gender from memeber_info where id=id;
if (str = 'Male') then
select '12345' ;
end if;
select '123' ;
END

我的过程是重新调谐
male
,而我需要它返回
123
。如何实现这一点?

您可以使用
case

select case when gender = 'Male'
            then 12345
            else 123
       end as some_name
from memeber_info
where id=id;

在java中,您可以使用函数从
语句
获取下一个结果集。该方法返回一个布尔值,如果有更多可用的结果集,则该值为真。

谢谢您的帮助,但我可以在结果中使用第二个选择查询输出吗?如果您正在使用,则可以。不确定其他API。