简体   繁体   English

从MySQL存储过程返回值

[英]returning values from MySQL stored procedure

I have created one stored procedure and its functioning well, what I am wanting is right now there is only one SQL statement in the stored procedure which is returning the expected values, can I add multiple SQL statements which will be resulting multiple vlues. 我已经创建了一个存储过程,并且其运行良好,我想要的是现在存储过程中只有一个SQL语句返回期望值,我可以添加多个SQL语句来生成多个vlues。 Please let me know. 请告诉我。

Here is my stored procedure 这是我的存储过程

DELIMITER //
CREATE PROCEDURE amazonall(IN client_ids INT(11))
BEGIN
SELECT SUM(total_inserted) into ti from log_amazon_import  where client_id = client_ids and date_format(created_date,'%Y-%m-%d') between DATE_SUB(CURDATE(),INTERVAL 1 WEEK) and CURDATE();
END //
DELIMITER ;

and also please let me know how can I access those return values, thanks in advance. 另外,请提前告知我如何访问这些返回值。

Yes, you can. 是的你可以。 If you want to return multiple records - just return the data set. 如果要返回多个记录-只需返回数据集即可。

  • Populate (temporary) tables and read them after. 填充(临时)表,然后读取它们。
  • Just run SELECT statements (without INTO) and read data set in the application, I know that mysqli extension allows it (functions: more_results , next_result , ...). 只需运行SELECT语句(不使用INTO)并读取应用程序中的数据集,我知道mysqli扩展允许它(功能: more_resultsnext_result ,...)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM