【问题标题】:Taking long time and has no output with the stored procedure耗时长,存储过程无输出
【发布时间】:2017-04-24 13:48:01
【问题描述】:

我正在执行下面的存储过程

CREATE PROCEDURE pn_s_pnl.`Takeoffone`()
 BEGIN
SELECT 
 ( select service_display_nm from billing_services_t) as bundle ,
 (select product_type_nm from billing_product_type_t) as package 
 ;
END;

但是在我单独执行语句时,它需要很长时间并且没有结果,

select service_display_nm from billing_services_t;
select product_type_nm from billing_product_type_t

我很快就会得到结果,存储过程是否无法返回该列的所有行,我没有得到。

【问题讨论】:

  • 每个结果返回多少条记录。似乎,如果两个查询中都有很多记录,那么您最终会得到一个怪物笛卡尔积结果。比如如果 bill_services_t 有 1000 条记录,而 bill_product_type_t 有 5000 条记录,那么您最终会得到 1000*5000=5,000,000。感觉像xy problem
  • 你想得到什么结果?看起来您缺少 JOINWHERE 子句。

标签: mysql stored-procedures


【解决方案1】:

我把它写成,

CREATE PROCEDURE pn_s_pnl.`Takeoffone`()
 BEGIN
select service_display_nm from billing_services_t as bundle ;
 select product_type_nm from billing_product_type_t as package 
;
END;

这工作正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    相关资源
    最近更新 更多