将此pl sql脚本转换为存储过程

时间:2014-03-31 15:45:43

标签: oracle plsql

我需要将其转换为Oracle过程,以便我可以在SSRS中将其用于报告。 SSRS无法执行脚本,因此必须将其转换为过程。或者如果可能的话,可以转换为单个select语句。目的是返回一个数据集,以便它可以被SSRS使用,但SSRS可以通过oracle客户端驱动程序工作,并且只能理解简单语句(单选)或存储过程。我对pl sql知之甚少。 P.S:Oracle 9i。

还需要在proc中实现3个参数(下面的代码中的参数1,2,3)。

    CREATE TABLE ggcus.ggcus_tmp_imo_discount(
    week_id INT
    ,web_discount_code VARCHAR2(100)
    ,promotion_type VARCHAR2(100)
    ,AS01 NUMBER(12,6)
    ,AS02 NUMBER(12,6)
    ,AS03 NUMBER(12,6)
    ,AS04 NUMBER(12,6)
    ,AS05 NUMBER(12,6)
    ,AS06 NUMBER(12,6)
    ,AS07 NUMBER(12,6)
    ,AS08 NUMBER(12,6)
    ,AS09 NUMBER(12,6)
    ,AS10 NUMBER(12,6)
    ,AS11 NUMBER(12,6)
    ,AS12 NUMBER(12,6)
    ,AS13 NUMBER(12,6)
    ,AS14 NUMBER(12,6)
    ,AS15 NUMBER(12,6)
    ,AS16 NUMBER(12,6)
    ,AS17 NUMBER(12,6)
    ,AS18 NUMBER(12,6)
    ,AS19 NUMBER(12,6)
    ,AS20 NUMBER(12,6)
    ,KB01 NUMBER(12,6)
    ,KB04 NUMBER(12,6)
    ,KB05 NUMBER(12,6)
    ,KBNW NUMBER(12,6)
    ,KBDN NUMBER(12,6)
    ,adjusted_amount NUMBER(12,6)
    );

    DECLARE l_to_date DATE;

      CURSOR c1 IS 
        SELECT week_id, from_date , to_date
          FROM ggcus_calendar
        WHERE year_id = 7 --[parameter1]
        ORDER BY week_id;

    BEGIN

     FOR r1 IN c1 LOOP
      l_to_date := r1.to_date + 1;

      INSERT INTO ggcus.ggcus_tmp_imo_discount
      SELECT  
                R1.week_id,
                disc.web_discount_id web_discount_code,
                hdr.description promotion_type,

                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS01' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS01,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS02' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS02,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS03' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS03,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS04' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS04,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS05' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS05,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS06' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS06,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS07' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS07,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS08' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS08,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS09' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS09,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS10' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS10,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS11' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS11,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS12' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS12,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS13' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS13,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS14' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS14,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS15' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS15,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS16' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS16,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS17' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS17,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS18' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS18,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS19' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS19,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS20' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS20,            
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'KB01' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KB01,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'KB04' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KB04,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'KB05' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KB05,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'KBNW' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KBNW,
                (CASE WHEN ctg.segment1|| ctg.segment2 = 'KBDN' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KBDN,
                (DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)) adjusted_amount
         FROM   oe_order_headers_all ooh,
                oe_order_lines_all ool,
                oe_transaction_types_tl oot,
                oe_transaction_types_all trx_type,
                oe_price_adjustments opa,
                mtl_system_items_b msi,
                ar_vat_tax_all_b vat,
                mtl_categories_b ctg,
                mtl_item_categories mic,
                mtl_category_sets_tl mcs,
                hz_cust_accounts hca,
                hz_parties hp,
                ggcus_web_discount_mappings disc,
                qp_list_headers_tl hdr
        WHERE       1 = 1
                AND trx_type.attribute1 = 'INT'
                AND ooh.header_id = ool.header_id
                AND ooh.ordered_DATE >= '18-MAR-2012' -- parameter 2
                AND ooh.ordered_DATE < '19-MAR-2012' -- parameter 3
                AND ooh.order_type_id = trx_type.transaction_type_id
                AND trx_type.transaction_type_id = oot.transaction_type_id
                AND oot.language = 'US'
                AND ooh.flow_status_code != 'CANCELLED'
                AND ooh.booked_flag = 'Y'
                AND ool.flow_status_code != 'CANCELLED'
                AND ool.booked_flag = 'Y'
                AND msi.organization_id = 101
                AND msi.inventory_item_id = ool.inventory_item_id
                AND ooh.ordered_date BETWEEN NVL (vat.start_date, SYSDATE)
                                         AND  NVL (vat.end_date, SYSDATE)
                AND ool.tax_code = vat.tax_code
                AND mcs.category_set_name = 'GGI Inventory'
                AND mic.category_set_id = mcs.category_set_id
                AND ctg.category_id = mic.category_id
                AND mcs.language = 'US'
                AND mic.inventory_item_id = ool.inventory_item_id
                AND mic.organization_id = 101
                AND opa.line_id = ool.line_id
                AND opa.list_line_type_code = 'DIS'
                AND opa.attribute1 = disc.web_discount_id
                AND opa.applied_flag = 'Y'
                AND opa.header_id = ooh.header_id
                AND hca.cust_account_id = ooh.sold_to_org_id
                AND hca.party_id = hp.party_id
                AND hdr.name = disc.modifier_name
                AND ooh.ordered_date >= r1.from_date
                AND ooh.ordered_date < l_to_date;

         COMMIT;

       END LOOP;
    END;

    SELECT
         Week_Id
        ,Web_Discount_Code
        ,Promotion_Type
        ,SUM(AS01)
        ,SUM(AS02)
        ,SUM(AS03)
        ,SUM(AS04)
        ,SUM(AS05)
        ,SUM(AS06)
        ,SUM(AS07)
        ,SUM(AS08)
        ,SUM(AS09)
        ,SUM(AS10)
        ,SUM(AS11)
        ,SUM(AS12)
        ,SUM(AS13)
        ,SUM(AS14)
        ,SUM(AS15)
        ,SUM(AS16)
        ,SUM(AS17)
        ,SUM(AS18)
        ,SUM(AS19)
        ,SUM(AS20)
        ,SUM(KB01)
        ,SUM(KB04)
        ,SUM(KB05)
        ,SUM(KBNW)
        ,SUM(KBDN)
        ,SUM(adjusted_amount)
    FROM ggcus.ggcus_tmp_imo_discount
    GROUP BY Week_Id, Web_Discount_Code, Promotion_Type
    ;


    DROP TABLE ggcus.ggcus_tmp_imo_discount;

1 个答案:

答案 0 :(得分:0)

在你阅读代码之前 - 请注意你在那里运行一个sql - 你不做任何事情。

我在这里写的是通用的方法 - 它不会编译 - 因为你必须在不同的行上编辑字符串(每一行都以#34;&#39; &#34;,并将以&#34; ||&#39;&#34;。

开头

注意&#34;立即执行&#34;对于DDL来说。

了解全局临时表 - 这将使您的生活更加简单!

建议不要在PL / SQL中创建和删除表格! 如果您有意做到这一点 - 90%你会做出错误

你的代码看起来像那样:

create procedure procname IS
  l_to_date DATE; 

  CURSOR c1 IS 
    SELECT week_id, from_date , to_date
      FROM ggcus_calendar
    WHERE year_id = 7 --[parameter1]
    ORDER BY week_id;
BEGIN

execute immediate 'CREATE TABLE ggcus.ggcus_tmp_imo_discount(
week_id INT
,web_discount_code VARCHAR2(100)
,promotion_type VARCHAR2(100)
,AS01 NUMBER(12,6)
,AS02 NUMBER(12,6)
,AS03 NUMBER(12,6)
,AS04 NUMBER(12,6)
,AS05 NUMBER(12,6)
,AS06 NUMBER(12,6)
,AS07 NUMBER(12,6)
,AS08 NUMBER(12,6)
,AS09 NUMBER(12,6)
,AS10 NUMBER(12,6)
,AS11 NUMBER(12,6)
,AS12 NUMBER(12,6)
,AS13 NUMBER(12,6)
,AS14 NUMBER(12,6)
,AS15 NUMBER(12,6)
,AS16 NUMBER(12,6)
,AS17 NUMBER(12,6)
,AS18 NUMBER(12,6)
,AS19 NUMBER(12,6)
,AS20 NUMBER(12,6)
,KB01 NUMBER(12,6)
,KB04 NUMBER(12,6)
,KB05 NUMBER(12,6)
,KBNW NUMBER(12,6)
,KBDN NUMBER(12,6)
,adjusted_amount NUMBER(12,6)
);';


 FOR r1 IN c1 LOOP
  l_to_date := r1.to_date + 1;

  INSERT INTO ggcus.ggcus_tmp_imo_discount
  SELECT  
            R1.week_id,
            disc.web_discount_id web_discount_code,
            hdr.description promotion_type,

            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS01' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS01,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS02' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS02,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS03' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS03,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS04' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS04,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS05' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS05,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS06' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS06,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS07' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS07,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS08' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS08,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS09' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS09,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS10' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS10,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS11' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS11,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS12' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS12,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS13' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS13,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS14' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS14,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS15' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS15,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS16' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS16,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS17' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS17,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS18' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS18,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS19' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS19,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'AS20' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) AS20,            
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'KB01' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KB01,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'KB04' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KB04,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'KB05' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KB05,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'KBNW' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KBNW,
            (CASE WHEN ctg.segment1|| ctg.segment2 = 'KBDN' THEN DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)  ELSE 0 END) KBDN,
            (DECODE (ool.line_category_code,'RETURN', opa.adjusted_amount * -1,opa.adjusted_amount)) adjusted_amount
     FROM   oe_order_headers_all ooh,
            oe_order_lines_all ool,
            oe_transaction_types_tl oot,
            oe_transaction_types_all trx_type,
            oe_price_adjustments opa,
            mtl_system_items_b msi,
            ar_vat_tax_all_b vat,
            mtl_categories_b ctg,
            mtl_item_categories mic,
            mtl_category_sets_tl mcs,
            hz_cust_accounts hca,
            hz_parties hp,
            ggcus_web_discount_mappings disc,
            qp_list_headers_tl hdr
    WHERE       1 = 1
            AND trx_type.attribute1 = 'INT'
            AND ooh.header_id = ool.header_id
            AND ooh.ordered_DATE >= '18-MAR-2012' -- parameter 2
            AND ooh.ordered_DATE < '19-MAR-2012' -- parameter 3
            AND ooh.order_type_id = trx_type.transaction_type_id
            AND trx_type.transaction_type_id = oot.transaction_type_id
            AND oot.language = 'US'
            AND ooh.flow_status_code != 'CANCELLED'
            AND ooh.booked_flag = 'Y'
            AND ool.flow_status_code != 'CANCELLED'
            AND ool.booked_flag = 'Y'
            AND msi.organization_id = 101
            AND msi.inventory_item_id = ool.inventory_item_id
            AND ooh.ordered_date BETWEEN NVL (vat.start_date, SYSDATE)
                                     AND  NVL (vat.end_date, SYSDATE)
            AND ool.tax_code = vat.tax_code
            AND mcs.category_set_name = 'GGI Inventory'
            AND mic.category_set_id = mcs.category_set_id
            AND ctg.category_id = mic.category_id
            AND mcs.language = 'US'
            AND mic.inventory_item_id = ool.inventory_item_id
            AND mic.organization_id = 101
            AND opa.line_id = ool.line_id
            AND opa.list_line_type_code = 'DIS'
            AND opa.attribute1 = disc.web_discount_id
            AND opa.applied_flag = 'Y'
            AND opa.header_id = ooh.header_id
            AND hca.cust_account_id = ooh.sold_to_org_id
            AND hca.party_id = hp.party_id
            AND hdr.name = disc.modifier_name
            AND ooh.ordered_date >= r1.from_date
            AND ooh.ordered_date < l_to_date;

     COMMIT;

   END LOOP;

SELECT
     Week_Id
    ,Web_Discount_Code
    ,Promotion_Type
    ,SUM(AS01)
    ,SUM(AS02)
    ,SUM(AS03)
    ,SUM(AS04)
    ,SUM(AS05)
    ,SUM(AS06)
    ,SUM(AS07)
    ,SUM(AS08)
    ,SUM(AS09)
    ,SUM(AS10)
    ,SUM(AS11)
    ,SUM(AS12)
    ,SUM(AS13)
    ,SUM(AS14)
    ,SUM(AS15)
    ,SUM(AS16)
    ,SUM(AS17)
    ,SUM(AS18)
    ,SUM(AS19)
    ,SUM(AS20)
    ,SUM(KB01)
    ,SUM(KB04)
    ,SUM(KB05)
    ,SUM(KBNW)
    ,SUM(KBDN)
    ,SUM(adjusted_amount)
FROM ggcus.ggcus_tmp_imo_discount
GROUP BY Week_Id, Web_Discount_Code, Promotion_Type
;


execute immediate 'DROP TABLE ggcus.ggcus_tmp_imo_discount';
end;

使用临时表,你必须运行一次:

CREATE GLOBAL TEMPORARY TABLE ggcus.ggcus_tmp_imo_discount(
    week_id INT
    ,web_discount_code VARCHAR2(100)
    ,promotion_type VARCHAR2(100)
    ,AS01 NUMBER(12,6)
    ,AS02 NUMBER(12,6)
    ,AS03 NUMBER(12,6)
    ,AS04 NUMBER(12,6)
    ,AS05 NUMBER(12,6)
    ,AS06 NUMBER(12,6)
    ,AS07 NUMBER(12,6)
    ,AS08 NUMBER(12,6)
    ,AS09 NUMBER(12,6)
    ,AS10 NUMBER(12,6)
    ,AS11 NUMBER(12,6)
    ,AS12 NUMBER(12,6)
    ,AS13 NUMBER(12,6)
    ,AS14 NUMBER(12,6)
    ,AS15 NUMBER(12,6)
    ,AS16 NUMBER(12,6)
    ,AS17 NUMBER(12,6)
    ,AS18 NUMBER(12,6)
    ,AS19 NUMBER(12,6)
    ,AS20 NUMBER(12,6)
    ,KB01 NUMBER(12,6)
    ,KB04 NUMBER(12,6)
    ,KB05 NUMBER(12,6)
    ,KBNW NUMBER(12,6)
    ,KBDN NUMBER(12,6)
    ,adjusted_amount NUMBER(12,6)
    ) ON COMMIT DELETE ROWS;

并且你的程序根本不需要改变(只需添加&#34;创建程序procname是&#34;在它之前。

运行程序后,所有数据都将出现在表中,直到您手动提交或删除它为止。

临时表的巨大好处 - 它是会话私有的。

多个会话可以并行运行 - 每个会话只会获得结果,而未运行该过程的会话将不会看到任何记录。

底线 - 阅读临时表...