插入值时出现“ORA_00913 Oracle错误-值太多”

yxyvkwin  于 2023-08-04  发布在  Oracle
关注(0)|答案(2)|浏览(163)

下面的代码是存储过程,他们告诉我把它转换成嵌套循环并尝试运行它。

insert into PRICEVIEW_RATE_PLAN_PROC (
    SSR_CODE
    ,CORRIDOR_PLAN_ID
    ,CORRIDOR_PLAN_DESCRIPTION
    ,USAGE_TYPE
    ,PRODUCT
    ,JURISDICTION
    ,PROVIDER
    ,RATE_PERIOD
    ,FLAGFALL
    ,RATE
    ,RATEBAND
    ,NUMSECS
    ,BAND_RATE
    ,ACTIVE_DT
    ,INACTIVE_DT
    )
select /*+ use_hash(rate_usage_overrides,corridor_plan_id_values,product_elements,descriptions,jurisdictions,rate_usage_bands_overrides) */
    distinct decode(a.corridor_plan_id, 0, '''', (
            select c.short_display
            from corridor_plan_id_values c
            where a.corridor_plan_id = c.corridor_plan_id
            )) as SSR_CODE
    ,a.corridor_plan_id as CORRIDOR_PLAN_ID
    ,decode(a.corridor_plan_id, 0, '''', (
            select d.display_value
            from corridor_plan_id_values d
            where a.corridor_plan_id = d.corridor_plan_id
            )) as CORRIDOR_PLAN_DESCRIPTION
    ,decode(a.type_id_usg, 0, '''', (
            select f.description_text
            from usage_types e
                ,descriptions f
            where a.type_id_usg = e.type_id_usg
                and e.description_code = f.description_code
            )) as USAGE_TYPE
    ,decode(a.element_id, 0, '''', (
            select h.description_text
            from product_elements g
                ,descriptions h
            where a.element_id = g.element_id
                and g.description_code = h.description_code
            )) as PRODUCT
    ,decode(a.jurisdiction, 0, '''', (
            select j.description_text
            from jurisdictions i
                ,descriptions j
            where a.jurisdiction = i.jurisdiction
                and j.description_code = i.description_code
            )) as JURISDICTION
    ,decode(a.provider_class, 0, '''', (
            select k.display_value
            from provider_class_values k
            where a.provider_class = k.provider_class
            )) as PROVIDER
    ,decode(a.rate_period, '' 0 '', '''', (
            select l.display_value
            from rate_period_values l
            where a.rate_period = l.rate_period
            )) as RATE_PERIOD
    ,(a.FIXED_CHARGE_AMT / 100) + (a.ADD_FIXED_AMT / 10000000) as FLAGFALL
    ,(a.ADD_UNIT_RATE / 10000000) * 60 as RATE
    ,b.RATEBAND as RATEBAND
    ,b.NUM_UNITS as NUMSECS
    ,(b.UNIT_RATE / 10000000) * 60 as BAND_RATE
    ,a.ACTIVE_DT as ACTIVE_DT
    ,a.INACTIVE_DT as INACTIVE_DT
from rate_usage_overrides a
    ,rate_usage_bands_overrides b
where a.seqnum = b.seqnum(+);

字符串

**我将上面的代码转换为嵌套循环,请在下面找到转换的嵌套循环,当我尝试运行下面的脚本时,它提示我一个错误:太多的价值观。你能告诉我到底是什么问题吗

insert into PRICEVIEW_RATE_PLAN_PROC(
  SSR_CODE,
  CORRIDOR_PLAN_DESCRIPTION,
  USAGE_TYPE,
  PRODUCT,
  JURISDICTION,
  PROVIDER,
  RATE_PERIOD,
  FLAGFALL,
  RATE,
  RATEBAND,
  NUMSECS,
  BAND_RATE,
  ACTIVE_DT,
  INACTIVE_DT
) VALUES (

  (select c.short_display AS SSR_CODE from rate_usage_overrides a,corridor_plan_id_values c where a.corridor_plan_id = c.corridor_plan_id),

  (select d.display_value AS CORRIDOR_PLAN_DESCRIPTION from rate_usage_overrides a ,corridor_plan_id_values d where a.corridor_plan_id = d.corridor_plan_id),

  (select f.description_text AS USAGE_TYPE from rate_usage_overrides a ,usage_types e, descriptions f where a.type_id_usg = e.type_id_usg and e.description_code = f.description_code ),

  (select h.description_text AS PRODUCT from rate_usage_overrides a, product_elements g,descriptions h where a.element_id = g.element_id and g.description_code = h.description_code ),

  (select j.description_text AS JURISDICTION from rate_usage_overrides a, jurisdictions i,descriptions j where a.jurisdiction = i.jurisdiction and j.description_code = i.description_code),

  (select k.display_value AS PROVIDER from rate_usage_overrides a ,provider_class_values k where a.provider_class = k.provider_class),

  (select l.display_value AS RATE_PERIOD from rate_usage_overrides a ,rate_period_values l where a.rate_period = l.rate_period),

  (select (a.FIXED_CHARGE_AMT/100) + (a.ADD_FIXED_AMT/10000000) AS FLAGFALL from rate_usage_overrides a AS ACTIVE_DT),

  (select (a.ADD_UNIT_RATE/10000000) * 60 AS RATE from rate_usage_overrides a),

  (select b.RATEBAND AS RATEBAND from rate_usage_bands_overrides b),

  (select b.NUM_UNITS AS NUMSECS from rate_usage_bands_overrides b),

  (select (b.UNIT_RATE/10000000) * 60 AS BAND_RATE from rate_usage_bands_overrides b),

  (select a.ACTIVE_DT,a.seqnum,b.seqnum  AS ACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+)),

  (select a.INACTIVE_DT,a.seqnum,b.seqnum  AS INACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+))

aamkag61

aamkag611#

这是你的错误

(select a.ACTIVE_DT,a.seqnum,b.seqnum  AS ACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+)),

  (select a.INACTIVE_DT,a.seqnum,b.seqnum  AS INACTIVE_DT from rate_usage_overrides a, rate_usage_bands_overrides b where a.seqnum = b.seqnum(+))

字符串
这两个查询将返回3个字段,但插入只指定一列,这就是为什么你得到这个错误。顺便说一下,这不是一个bug

b09cbbtk

b09cbbtk2#

使用第一次查询中的c.corridor_plan_id对病房运行单个查询,并检查至少有一个查询返回多个值

相关问题