使用IN参数作为Record的过程插入多个表

时间:2015-07-06 13:03:21

标签: plsql oracle11g plsqldeveloper

我需要将数据插入表中,我的程序将通过JAVA调用。

所以JAVA的人问我是否可以将JAVA的对象(PLSQL中的记录)作为输入,然后将其插入表中。

这些是表格的DDL

create table gnv_sol_attributes (

so_id    varchar2(20),           

se_integration_id    varchar2(20),           

parameter_name    varchar2(100),           

action_code    varchar2(20),           

parameter_value    varchar2(255)

);



 create table

gnv_sol_serviceelement (

customer_ref    varchar2(20),           

billing_account_code    varchar2(20),           

so_id    varchar2(20),           

so_type    varchar2(5),           

se_integration_id    varchar2(20),           

se_root_integration_id    varchar2(20),           

se_parent_integration_id    varchar2(20),       

offer_id    varchar2(75),       

offer_id_old    varchar2(75),       

pricing_id    varchar2(75),       

promo_id    varchar2(20),       

action_code    varchar2(20),           

reason_id    varchar2(100),       

product_code    varchar2(40),           

product_subsc_date    date,       

product_start_date    date,           

product_modify_date    date,       

product_end_date    date,       

event_source    varchar2(40),       

sales_force_code    varchar2(20),       

line_number    varchar2(20),       

product_status    varchar2(2)

);

因此在单个so_id和se_integration_id的gnv_sol_attributes表中有不同的parameter_name。

在这里他们解释我喜欢在记录中我们可以另一个记录然后插入它(看起来像多维集合)。

gnv_sol_serviceelemen表的示例数据

CUSTOMER_REF,BILLING_ACCOUNT_CODE,SO_ID,SO_TYPE,SE_INTEGRATION_ID,SE_ROOT_INTEGRATION_ID,SE_PARENT_INTEGRATION_ID,OFFER_ID,OFFER_ID_OLD,PRICING_ID,PROMO_ID,ACTION_CODE,REASON_ID,PRODUCT_CODE,PRODUCT_SUBSC_DATE,PRODUCT_START_DATE,PRODUCT_MODIFY_DATE,PRODUCT_END_DATE,EVENT_SOURCE,SALES_FORCE_CODE,LINE_NUMBER,PRODUCT_STATUS

C_1,BA_1,SO_1,OT_1,SE_1,SE_1,SE_1,STDE_A8,,STDE_A8_FEE_AE,,Add,,STDE_A8,7/13/2015,7/13/2015,,,,,1,

C_1,BA_1,SO_1,OT_1,SE_2,SE_1,SE_1,STDE_A8,,STDE_MA,,Add,,STDE_MA,7/14/2015,7/14/2015,,,,,2,

C_1,BA_1,SO_1,OT_1,SE_3,SE_1,SE_1,STDE_A8,,STDE_WIFI,,Add,,STDE_WIFI,7/15/2015,7/15/2015,,,,,3,

C_1,BA_1,SO_1,OT_1,SE_4,SE_1,SE_1,STDE_A8,,STDE_BCK_M_FEE_AE,,Add,,STDE_BCK_M,7/16/2015,7/16/2015,,,,,4,

C_1,BA_1,SO_1,OT_1,SE_5,SE_1,SE_1,STDE_A8,,SBRI_1_FEE_AE,,Add,,SBRI_1,7/17/2015,7/17/2015,,,,,5,

C_1,BA_1,SO_1,OT_1,SE_6,SE_1,SE_1,STDE_A8,,SBRI_6_FEE_AE,,Add,,SBRI_4,7/18/2015,7/18/2015,,,,,6,

C_1,BA_1,SO_1,OT_1,SE_7,SE_1,SE_1,STDE_A8,,SPUN_6_FEE_AE,,Add,,SPUN_6,7/19/2015,7/19/2015,,,,,7,

C_1,BA_1,SO_1,OT_1,SE_8,SE_1,SE_7,STDE_A8,,SPUN_AV_6,,Add,,SPUN_AV_6,7/20/2015,7/20/2015,,,,,8,

C_1,BA_1,SO_1,OT_1,SE_9,SE_1,SE_7,STDE_A8,,SPUN_AF_6,,Add,,SPUN_AF_6,7/21/2015,7/21/2015,,,,,9,

C_1,BA_1,SO_1,OT_1,SE_10,SE_1,SE_7,STDE_A8,,SPUN_ARS_6,,Add,,SPUN_ARS_6,7/22/2015,7/22/2015,,,,,10,

C_1,BA_1,SO_1,OT_1,SE_11,SE_1,SE_1,STDE_A8,,SCOE_VOIP_CEIP_3_FEE_AE,,Add,,SCOE_VOIP_CEIP_3,7/23/2015,7/23/2015,,,,,11,

gnv_sol_attributes的样本数据

SO_ID,SE_INTEGRATION_ID,PARAMETER_NAME,ACTION_CODE,PARAMETER_VALUE,

1,SO_1,SE_1,PCT? (Without),Add,?,

2,SO_1,SE_1,FEE PCT,Add,110,

3,SO_1,SE_1,AE PCT,Add,212,

4,SO_1,SE_1,AE+FEE PCT,Add,218,

5,SO_1,SE_1,FEE BOO,Add,YES,

6,SO_1,SE_1,AE BOO,Add,YES,

7,SO_1,SE_1,AE+FEE BOO,Add,YES,

8,SO_1,SE_1,hierarchy ID,Add,,

9,SO_1,SE_1,hierarchy subscription ID,Add,,

10,SO_1,SE_1,hierarchy parent ID,Add,,

11,SO_1,SE_1,subscription date,Add,7/31/2015,

12,SO_1,SE_1,start of charging date,Add,7/31/2015,

13,SO_1,SE_1,start of billing date,Add,7/31/2015,

14,SO_1,SE_1,PAS(Address),Add,,

15,SO_1,SE_1,Download Bandwidth,Add,20480,

16,SO_1,SE_1,upload bandwidth,Add,1024,

我创建了这个过程,并且它成功地在两个表中插入了一行。

create or replace procedure ins_svc (p_svc IN SVC_REC,            p_svc_att IN SVC_ATTR_REC)

is



begin



insert into gnv_sol_serviceelement values (p_svc.customer_ref,    p_svc.billing_account_code, p_svc.so_id, p_svc.so_type

                                       ,p_svc.se_integration_id, p_svc.se_root_integration_id, p_svc.se_parent_integration_id

                                       ,p_svc.offer_id, p_svc.offer_id_old, p_svc.pricing_id, p_svc.promo_id, p_svc.action_code

                                       ,p_svc.reason_id, p_svc.product_code, p_svc.product_subsc_date, p_svc.product_start_date

                                       ,p_svc.product_modify_date, p_svc.product_end_date, p_svc.event_source

                                       ,p_svc.sales_force_code, p_svc.line_number, p_svc.product_status);



insert into GNV_SOL_ATTRIBUTES values (p_svc_att.so_id, p_svc_att.se_integration_id, p_svc_att.parameter_name

                                   ,p_svc_att.action_code, p_svc_att.parameter_value);



exception

 when others then

 dbms_output.put_line('error code '||' '||sqlcode||' '||'Error reason'||sqlerrm);

end;

现在,JAVA的人问我是否有任何方法可以在gnv_sol_serviceelemen表中插入一行

和gnv_sol_attributes中的多行,因为在属性表中,相同的so_id和SE_INTEGRATION_ID有不同的参数值。

这是我被卡住的地方。

如果有人有出路。

数据库版本: -

Oracle Database 11g企业版11.2.0.3.0版 - 64位生产

0 个答案:

没有答案