oracle 嵌套表

--自定义对象

CREATE OR REPLACE TYPE Fas_checksheetinfo_line_obj AS OBJECT
(
  CSID_ID           VARCHAR2(32),--报账单明细ID
  CSI_ID            VARCHAR2(32),--报账单ID
  CSID_GENERATEDATE DATE,        --费用发生日期
  CSID_TYPE         VARCHAR2(32),--费用类型
  CSID_SUMMARY      VARCHAR2(256),--费用摘要
  CSID_CURRENCY     VARCHAR2(32),--币种
  CSID_VALUE        NUMBER,      --费用发生金额
  CREATEDBY         VARCHAR2(32),--生成人
  CREATEDDATE       DATE,        --生成日期
  LASTUPDATEDBY     VARCHAR2(32),--最后更改人
  LASTUPDATEDDATE   DATE,        --最后更改日期
  FLAG              VARCHAR2(32),--删除标识
  CSID_SEQ          NUMBER       --序号
)


 

自定义 table object

CREATE OR REPLACE TYPE Fas_checksheetinfo_line_tab AS TABLE OF Fas_checksheetinfo_line_obj;


 

pck

PROCEDURE checksheet_import(P_CSI_ID                  IN VARCHAR2, --报账单ID
                              P_CSI_CODE                IN VARCHAR2, --报账单编号
                              P_RI_ID                   IN VARCHAR2, --凭证ID
                              P_CSI_VALUE               IN NUMBER, --报账单金额
                              P_CSI_ORG                 IN VARCHAR2, --报账单位
                              P_CREATEDBY               IN VARCHAR2, --生成人
                              P_CREATEDDATE             IN DATE,     --生成日期
                              P_LASTUPDATEDBY           IN VARCHAR2, --最后更改人
                              P_LASTUPDATEDDATE         IN DATE,     --最后更改日期
                              P_FLAG2                   IN VARCHAR2, --删除标识
                              P_CSI_TYPE                IN VARCHAR2, --报账单类型
                              P_CSI_DEST                IN VARCHAR2, --目的地
                              P_CSI_GENERATEDATE        IN DATE,     --费用发生年月
                              P_CSI_COSTCENTER          IN VARCHAR2, --成本中心
                              P_CSI_SUMMARY             IN VARCHAR2, --摘要
                              P_CSI_PDFDIR              IN VARCHAR2, --pdf地址
                              P_GI_PDFDIR               IN VARCHAR2, --影像列表pdf地址
                              p_checksheetinfo_line_tab IN Fas_checksheetinfo_line_tab, --行信息,嵌套表
                              ----------------输出结果---------------------------
                              p_flag OUT NUMBER,
                              p_msg  OUT VARCHAR2) is
 
    v_cheksheet      ei_checksheetinfo%ROWTYPE;
    v_cheksheet_line ei_checksheetinfo_detail%ROWTYPE;
    v_line_count     number;
  begin
    null;
    p_flag := 0;
    p_msg := ‘success‘;
    --插入报账单头信息表
    insert into ei_checksheetinfo
      (CSI_ID,
       CSI_CODE,
       RI_ID,
       CSI_VALUE,
       CSI_ORG,
       CREATEDBY,
       CREATEDDATE,
       LASTUPDATEDBY,
       LASTUPDATEDDATE,
       FLAG,
       CSI_TYPE,
       CSI_DEST,
       CSI_GENERATEDATE,
       CSI_COSTCENTER,
       CSI_SUMMARY,
       CSI_PDFDIR,
       GI_PDFDIR)
    values
      (P_CSI_ID,
       P_CSI_CODE,
       P_RI_ID,
       P_CSI_VALUE,
       P_CSI_ORG,
       P_CREATEDBY,
       P_CREATEDDATE,
       P_LASTUPDATEDBY,
       P_LASTUPDATEDDATE,
       P_FLAG,
       P_CSI_TYPE,
       P_CSI_DEST,
       P_CSI_GENERATEDATE,
       P_CSI_COSTCENTER,
       P_CSI_SUMMARY,
       P_CSI_PDFDIR,
       P_GI_PDFDIR);
    --插入行信息数据
    v_line_count := p_checksheetinfo_line_tab.COUNT;
    FOR i IN 1 .. v_line_count LOOP
      --p_line_errmsg(i).line_number := v_invoice_line_info_arr(i).line_number;
      insert into EI_CHECKSHEETINFO_DETAIL
        (CSID_ID,
         CSI_ID,
         CSID_GENERATEDATE,
         CSID_TYPE,
         CSID_SUMMARY,
         CSID_CURRENCY,
         CSID_VALUE,
         CREATEDBY,
         CREATEDDATE,
         LASTUPDATEDBY,
         LASTUPDATEDDATE,
         FLAG,
         CSID_SEQ)
      values
        (p_checksheetinfo_line_tab(i).CSID_ID,
         p_checksheetinfo_line_tab(i).CSI_ID,
         p_checksheetinfo_line_tab(i).CSID_GENERATEDATE,
         p_checksheetinfo_line_tab(i).CSID_TYPE,
         p_checksheetinfo_line_tab(i).CSID_SUMMARY,
         p_checksheetinfo_line_tab(i).CSID_CURRENCY,
         p_checksheetinfo_line_tab(i).CSID_VALUE,
         p_checksheetinfo_line_tab(i).CREATEDBY,
         p_checksheetinfo_line_tab(i).CREATEDDATE,
         p_checksheetinfo_line_tab(i).LASTUPDATEDBY,
         p_checksheetinfo_line_tab(i).LASTUPDATEDDATE,
         p_checksheetinfo_line_tab(i).FLAG,
         p_checksheetinfo_line_tab(i).CSID_SEQ);
    END LOOP;
    commit;
  EXCEPTION
    WHEN OTHERS THEN
      p_flag := 101;
      p_msg  := SQLERRM;
  end checksheet_import;


 

测试脚本

declare
  checksheetinfo_line_tab Fas_checksheetinfo_line_tab;
  p_flag                  number;
  p_msg                   varchar2(200);
begin
  --插入主表

  --插入行表
  checksheetinfo_line_tab := Fas_checksheetinfo_line_tab();
  checksheetinfo_line_tab.extend;
  checksheetinfo_line_tab(1) := Fas_checksheetinfo_line_obj(CSID_ID           => 11,
                                                            CSI_ID            => 1,
                                                            CSID_GENERATEDATE => sysdate,
                                                            CSID_TYPE         => 11,
                                                            CSID_SUMMARY      => 11,
                                                            CSID_CURRENCY     => 11,
                                                            CSID_VALUE        => 11,
                                                            CREATEDBY         => 11,
                                                            CREATEDDATE       => sysdate,
                                                            LASTUPDATEDBY     => 11,
                                                            LASTUPDATEDDATE   => sysdate,
                                                            FLAG              => 11,
                                                            CSID_SEQ          => 11);
   --调用过程                                                       
  fas_checksheet_pkg.checksheet_import(1,
                                       1,
                                       1,
                                       1,
                                       1,
                                       1,
                                       sysdate,
                                       1,
                                       sysdate,
                                       1,
                                       1,
                                       1,
                                       sysdate,
                                       1,
                                       1,
                                       1,
                                       1,
                                       checksheetinfo_line_tab,
                                       p_flag,
                                       p_msg);
   --打印调用结果
   dbms_output.put_line(‘p_flag:‘ || p_flag || ‘,p_msg:‘ || p_msg);
end;

oracle 嵌套表,布布扣,bubuko.com

oracle 嵌套表

上一篇:SQLite cursor.moveToNext()


下一篇:64位Windows 7平台安装32位Timesten,配置ODBC数据源