首页 > 数据库 >list agg cause ORA-06502 PL/SQL: numeric or value error

list agg cause ORA-06502 PL/SQL: numeric or value error

时间:2023-07-24 23:07:28浏览次数:45  
标签:agg -- list recon facilityCusip error rec portfolioCusip loanxid


http://www.idb-stock.net/idb/2011/07/05/204.html

ora-06502错误主要是指数据字或值错误,包括以下子类型:字符到数据值的转换错误、字符串缓冲区太小、数值精度太高等。

对空集合的调用,会报ora-06502错误


declare
  type cnt_typ is table of number index by binary_integer;
  v_cnt1 cnt_typ;
begin
  select 1 bulk collect
    into v_cnt1
    from dual
   where 1 > 20;
  for i in v_cnt1.first .. v_cnt1.last
  loop
    dbms_output.put_line(v_cnt1(i));
  end loop;
end;
/

dw@dw>declare  2    type cnt_typ is table of number index by binary_integer;  3    v_cnt1 cnt_typ;  4  begin  5    select 1 bulk collect  6      into v_cnt1  7      from dual  8     where 1 > 20;  9    for i in v_cnt1.first .. v_cnt1.last 10    loop 11      dbms_output.put_line(v_cnt1(i)); 12    end loop; 13  end; 14  /declare*ERROR at line 1:ORA-06502: PL/SQL: numeric or value errorORA-06512: at line 9

对变量赋值时,值的长度超过了变量定义的长度,会报ora-06502错误



declare
  v_name varchar2(3);
begin
  v_name := 'Frank';
end;
/

declare
  v_n number(2);
begin
  v_n := 100;
end;
/

dw@dw>declare  2    v_name varchar2(3);  3  begin  4    v_name := 'Frank';  5  end;  6  /declare*ERROR at line 1:ORA-06502: PL/SQL: numeric or value error: character string buffer too smallORA-06512: at line 4dw@dw>declare  2    v_n number(2);  3  begin  4    v_n := 100;  5  end;  6  /declare*ERROR at line 1:ORA-06502: PL/SQL: numeric or value error: number precision too largeORA-06512: at line 4

字符转换为数字时,也会报ORA-06502字符到数据值的转换错误

declare
  v_n number(2) ;
begin
  v_n := 'a';
end;
/

dw@dw>declare  2    v_n number(2) ;  3  begin  4    v_n := 'a';  5  end;  6  /declare*ERROR at line 1:ORA-06502: PL/SQL: numeric or value error: character to number conversion errorORA-06512: at line 4dw@dw>

ORA-06502: PL/SQL: numeric or value errorstring
Cause: An arithmetic, numeric, string, conversion, or constraint error occurred. For example, this error occurs if an attempt is made to assign the value NULL to a variable declared NOT NULL, or if an attempt is made to assign an integer larger than 99 to a variable declared NUMBER(2).
Action: Change the data, how it is manipulated, or how it is declared so that values do not violate constraints.

===========

for r_rec in (
     --loanxid is null
     select portfolioCusip,portfolioname,facilityCusip,FACILITYNAME, TRADECCY,loanxid, sum(nvl(CommitmentAmount,0)) position,0.0 apolloWAVGPrice, --sum(commitmentamount*WTAVGPURCHASEPRICE)/sum(commitmentamount) apolloWAVGPrice,
     lv,lvname,
     sum(nvl(notionalAmount,0)) notional
     /*
     from GCD.PtrsPositionExtTMP tmp 
     group by portfolioCusip,facilityCusip,FIRMACCOUNTCD,TRADECCY,loanxid 
     */
     from GCD.PtrsPositionExt  tmp 
     where tmp.portfolioCusip in (select portfolioCusip from trustee_daily_position_recon where reporttype=p_reporttype and asofdate=p_date)
     and (loanxid is null or loanxid not like 'LX%') -- we have other values :NOUKMARK,NOLXBOND,NOTLOANX,NOLXMARK
     --group by portfolioCusip,facilityCusip, TRADECCY,loanxid 
     group by portfolioCusip,portfolioname,facilityCusip,  FACILITYNAME ,TRADECCY,loanxid, lv,lvname
     
     union
     
     --loanxid is not null
     select portfolioCusip,portfolioname,
     '' facilityCusip,
     '' FACILITYNAME,
     '' TRADECCY,
       (select listagg(facilitycusip,'|') within group (order by loanxid) from loanfacility where loanxid=tmp.loanxid group by loanxid) facilityCusip,
       (select listagg(facilityname,'|') within group (order by loanxid) from loanfacility where loanxid=tmp.loanxid group by loanxid) FACILITYNAME, 
       (select  listagg(globalccy, '|') within group(order by tt.loanxid)from (select distinct globalccy, loanxid from loanfacility  ) tt  where tt.loanxid=tmp.loanxid group by tt.loanxid) TRADECCY,
      loanxid, sum(nvl(CommitmentAmount,0)) position,0.0 apolloWAVGPrice, --sum(commitmentamount*WTAVGPURCHASEPRICE)/sum(commitmentamount) apolloWAVGPrice,
     lv,lvname,
     sum(nvl(notionalAmount,0)) notional
     /*
     from GCD.PtrsPositionExtTMP tmp 
     group by portfolioCusip,facilityCusip,FIRMACCOUNTCD,TRADECCY,loanxid 
     */
     from GCD.PtrsPositionExt  tmp 
     where tmp.portfolioCusip in (select portfolioCusip from trustee_daily_position_recon where reporttype=p_reporttype and asofdate=p_date)
       and loanxid is not null and loanxid like 'LX%'
     --group by portfolioCusip,facilityCusip, TRADECCY,loanxid 
     group by portfolioCusip,portfolioname,  loanxid, lv,lvname
    ) loop
     --dbms_output.put_line('for:'||r_rec.portfolioCusip||r_rec.facilityCusip);
     update trustee_daily_position_recon recon set apolloPosition=r_rec.position,  --facilityCusip=r_rec.facilityCusip,FACILITYNAME=r_rec.FACILITYNAME,
     apolloWAVGPrice=r_rec.apolloWAVGPrice, apolloNotional=r_rec.notional,
     APOLLOLOANXID=r_rec.loanxid
     where recon.portfolioCusip=r_rec.portfolioCusip 
     and ( (recon.facilityCusip=r_rec.facilityCusip and recon.trusteeIdentifierType not in ('LOANX_ID','LOANX_IDC') )
       or (recon.trusteeIdentifier=r_rec.loanxid and recon.trusteeIdentifierType in ('LOANX_ID','LOANX_IDC'))
      )
     and recon.lv=r_rec.lvname
   and reporttype=p_reporttype and asofdate=p_date;
     --and recon.Currency=r_rec.Currency;
     
      
     --dbms_output.put_line('after update:'||r_rec.portfolioCusip||r_rec.facilityCusip);
     select count(*) cnt into cntTmp from trustee_daily_position_recon recon
     where recon.portfolioCusip=r_rec.portfolioCusip 
     --and ( recon.facilityCusip=r_rec.facilityCusip or ((recon.trusteeIdentifier=r_rec.loanxid or recon.trusteeIdentifier=r_rec.facilityCusip) and recon.facilityCusip is null))
     and ( (recon.facilityCusip=r_rec.facilityCusip and recon.trusteeIdentifierType not in ('LOANX_ID','LOANX_IDC') )
       or (recon.trusteeIdentifier=r_rec.loanxid and recon.trusteeIdentifierType in ('LOANX_ID','LOANX_IDC'))
      )
     and recon.lv=r_rec.lvname;
     --dbms_output.put_line('before insert:'||r_rec.portfolioCusip||r_rec.facilityCusip||'+'||cntTmp);
     if (cntTmp = 0) then
      --dbms_output.put_line('insert:'||r_rec.portfolioCusip||r_rec.facilityCusip);
      insert into trustee_daily_position_recon (recordId,portfolioCusip,portfolioName,facilitycusip,FACILITYNAME,apolloLoanXID,trusteePosition,apolloPosition,Currency,apolloWAVGPrice,lv,asofdate,reporttype,trusteeNotional,apolloNotional,trusteeWAVGPrice) 
      values(GCD.trusteeRecon_Seq.nextval, r_rec.portfolioCusip,r_rec.portfolioName,r_rec.facilityCusip,r_rec.FACILITYNAME,r_rec.loanxid,0,r_rec.position, r_rec.Tradeccy,r_rec.apolloWAVGPrice,r_rec.lvname,p_date,p_reporttype,0,r_rec.notional,0);
     end if;
     --dbms_output.put_line('after insert:'||r_rec.portfolioCusip||r_rec.facilityCusip);
    end loop;

list agg 函数也会导致这个问题,目前原因未明。

标签:agg,--,list,recon,facilityCusip,error,rec,portfolioCusip,loanxid
From: https://blog.51cto.com/u_16174476/6840098

相关文章

  • android开发 - ListView
    android中很多应用都是用ListView来显示数据就像系统中的设置里面,每一行,就是构成的ListViewprivateListViewlistview;privatePersonServiceperson;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstan......
  • hadoop-eclipse开发环境搭建及error: failure to login错误
    对于Hadoop开发者来讲,通过JAVAAPI编程是进入Map-Reduce分布式开发的第一步。由于Eclipse本身并没有提供对MapReduce编程模式的支持,所以需要一些简单的步骤来实现。1.安装Hadoop。本文的Hadoop是部署在虚拟机上的伪分布模式。相关软件环境如下:JDK:sunjdk1.6.0_30Hadoop:hadoop-0......
  • 用Java集合中的Collections.sort方法对list排序的两种方法
    用Collections.sort方法对list排序有两种方法第一种是list中的对象实现Comparable接口,如下:   <strong>/**02 *根据order对User排序03 */04 publicclassUserimplementsComparable{05 privateStringname;06 privateIntegerorder;07 publicStringgetN......
  • 前端请求报错:'JSON parse error: syntax error, expect {, actual e…1, line 1, colu
    1、如果不用JSON.stringify(inputJson)包起来就会报错letinputJson={"selectUid":selectUid};varresponse=await$.ajax({type:'POST',url:'xxx',data:inputJson,//正确的是JSON.stringify(inputJson)......
  • SyntaxError: Expected property name or ‘}‘ in JsoN atposition 1
    1、在代码中通过JSON.parse()进行转换,发现如下图所示报错了。其实主要原因是单引号和双引号引起的问题。如果转义的字符串进行了赋值,那么上面一层代码会多了一层的转义。这里加2个JSON.parse()是因为,第一次转换的时候还是个字符串。我们要在json字符串前后手动加上双引号,然后在进......
  • 数组(Array)和链表(List)
    推荐https://cloud.tencent.com/developer/article/2304343引言在Java编程中,数组(Array)和链表(List)是常用的数据结构,用于在内存中存储和组织数据。两者都有各自的特点和适用场景,本文将深入比较数组与链表的区别,并结合代码示例进行详细解释。数组(Array)定义和特点数组是一种固定......
  • Vue项目启动 报错error:0308010C:digital envelope routines::unsupported
    出现这个错误是因为node.jsV17版本中最近发布的OpenSSL3.0,而OpenSSL3.0对允许算法和密钥大小增加了严格的限制,可能会对生态系统造成一些影响.解决方法package.json增加配置"scripts":{"serve":"setNODE_OPTIONS=--openssl-legacy-provider&&vue-cli-serviceserve......
  • ValueNotifier<T> ValueListenableBuilder<T> Stack() positioned.fill()
     1、在Column下面增加可以滚动的Row2、在widget外部控件其内部的变量ValueNotifier<T> ValueListenableBuilder<T>(valueListenable:...,builder:()=>)  import'package:flutter/material.dart';classSettingsPageextendsStatelessWidget{finalint_cou......
  • vue项目使用vue-virtual-scroll-list虚拟滚动超多千万条数据 cv可用案例
    当我们有大量数据需要显示在列表中时,传统的滚动列表会将所有数据渲染到DOM中,导致性能下降和内存占用增加。虚拟滚动列表通过仅渲染当前视窗内可见的一小部分数据,动态地根据滚动位置更新列表内容,从而实现更高效的列表渲染。vue-virtual-scroll-list是一个用于Vue.js的虚拟滚动......
  • .NET 6 swagger 隐藏接口
    如何实现".NET6Swagger隐藏接口"概述在.NET6中,Swagger是一个流行的API文档和测试工具,它可以帮助开发者快速了解和测试API接口。有时候我们可能会希望隐藏一些敏感接口或者不需要公开的接口,以达到安全性和简洁性的目的。本文将介绍如何在.NET6中使用Swagger隐藏......