简体   繁体   English

如何在 Oracle APEX 中使用弹出 LOV 插入多个值?

[英]How to insert multiple values with popup LOV in Oracle APEX?

I want to find a way to insert multiple values in a link table, for that I use popup LOV item, using this item users can choose multiple values.我想找到一种在链接表中插入多个值的方法,为此我使用弹出 LOV 项目,使用此项目用户可以选择多个值。 And I want to insert that values to link table.我想将该值插入链接表。

I tried with我试过了

INSERT INTO LINK_TABLE (FK_1, FK_2)
VALUES (:P2_POPUP, :P2_RECORD2);

When I try to insert more than one value, I got ORA-01722: invalid number当我尝试插入多个值时,我得到ORA-01722: invalid number

I presume that我认为

  • P2_POPUP contains a single value, while P2_POPUP包含单个值,而
  • P2_RECORD2 contains one or more values selected by user P2_RECORD2包含用户选择的一个或多个值
    • it means that Apex stores them as colon-separated values, which - furthermore...这意味着 Apex 将它们存储为冒号分隔的值,这 - 此外......
    • ... means that you have to split it into rows ...意味着您必须将其拆分为行

For example: TEMP CTE "simulates" values that P2_POPUP ( 1 ) and P2_RECORD2 ( 10:30:40 ) contain.例如: TEMP CTE “模拟” P2_POPUP ( 1 ) 和P2_RECORD2 ( 10:30:40 ) 包含的值。 Query from line #3 to line #6 creates several rows out of it:从第 3 行到第 6 行的查询从中创建了几行:

SQL> with temp (p2_popup, p2_record2) as
  2    (select 1, '10:30:40' from dual)
  3  select p2_popup,
  4    regexp_substr(p2_record2, '[^:]+', 1, level) p2_rec
  5  from temp
  6  connect by level <= regexp_count(p2_record2, ':') + 1;

  P2_POPUP P2_REC
---------- --------------------------------
         1 10
         1 30
         1 40

SQL>

It means that your code would look like this:这意味着您的代码将如下所示:

insert into link_table (fk_1, fk_2)
select :P2_POPUP,
       regexp_substr(:P2_RECORD2, '[^:]+', 1, level) p2_rec
from dual
connect by level <= regexp_count(:P2_RECORD2, ':') + 1;

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

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