Oracle for in loop循环时expression is of wrong type报错
来源:互联网 发布:悟空在线软件下载 编辑:程序博客网 时间:2024/06/05 15:22
1、我本来想做一个嵌套的for in loop循环插入。第一层查出代码,然后利用这个代码再查出所有的日期。但是使用这个日期的时候一直报错,如下:
BEGIN FOR item IN (SELECT DISTINCT SECINNERCODE,SECURITYCODE FROM FUND_BS_ATYPE WHERE ISUSABLE='1' AND TYPECODE IN (180108) ORDER BY SECINNERCODE) LOOP FOR item_date IN (SELECT CHANGEDATE FROM FUND_NV_NV WHERE SECURITYCODE=item.SECURITYCODE ORDER BY CHANGEDATE) LOOP INSERT INTO FUND_DRAWDOWN_INDEX(EID,SECINNERCODE,SECURITYCODE,MDDATE,MDDAILY,MD1W,MD4W,MD13W,MD52W,MD156W,MDY,MDST) VALUES(FUR_TRADE_SEQ.NEXTVAL,item.SECINNERCODE,item.SECURITYCODE,item_date,dbms_random.value(-0.2,0),dbms_random.value(-0.3,0),dbms_random.value(-0.35,0),dbms_random.value(-0.35,0),dbms_random.value(-0.4,0),dbms_random.value(-0.5,0),dbms_random.value(-0.7,0),dbms_random.value(-1,0)); END LOOP; END LOOP;END;
正确的是:
BEGIN FOR item IN (SELECT DISTINCT SECINNERCODE,SECURITYCODE FROM FUND_BS_ATYPE WHERE ISUSABLE='1' AND TYPECODE IN (180108) ORDER BY SECINNERCODE) LOOP FOR item_date IN (SELECT CHANGEDATE FROM FUND_NV_NV WHERE SECURITYCODE=item.SECURITYCODE ORDER BY CHANGEDATE) LOOP INSERT INTO FUND_DRAWDOWN_INDEX(EID,SECINNERCODE,SECURITYCODE,MDDATE,MDDAILY,MD1W,MD4W,MD13W,MD52W,MD156W,MDY,MDST) VALUES(FUR_TRADE_SEQ.NEXTVAL,item.SECINNERCODE,item.SECURITYCODE,item_date.CHANGEDATE,dbms_random.value(-0.2,0),dbms_random.value(-0.3,0),dbms_random.value(-0.35,0),dbms_random.value(-0.35,0),dbms_random.value(-0.4,0),dbms_random.value(-0.5,0),dbms_random.value(-0.7,0),dbms_random.value(-1,0)); END LOOP; END LOOP;END;
原因:
内层循环的时候,我们只查出了日期一个字段,然后在insert语句的时候直接用了这个item_date,其实是不对的,应该用item_date获取里面的字段。也就是item_date.CHANGEDATE。
阅读全文
0 0
- Oracle for in loop循环时expression is of wrong type报错
- oracle for in loop
- SSH报错之 Provided id of the wrong type for class model.User. Expected: class java.lang
- oracle优雅for 循环插入 in loop insert
- for in loop 循环语句
- "Expression of type "UIViewController?" is unused".
- 解决报错 CodeSign error: code signing is required for product type Application in SDK iOS
- MySQL报错“Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggre”
- Oracle APEX 报错List of Values not supported for this type
- Oracle/PLSQL: FOR Loop 循环语句
- Oracle中三种循环(For、While、Loop)
- oracle for循环loop的工作机制
- Oracle中三种循环(For、While、Loop)
- hibernate.TypeMismatchException: Provided id of the wrong type for class
- Provided id of the wrong type for class
- JSChart:Input data in wrong format for selected chart type
- eclipse 报错the hierarchy of the type is inconsis
- 报错:No enclosing instance of type ExtendsDemo is accessible.
- OpenCV学习笔记(10)分离颜色通道&多通道图像混合
- Android异步消息处理机制,从源码带你来解析
- tensorflow框架基础之简单网络训练
- 在线浏览swf文件
- Java上位机
- Oracle for in loop循环时expression is of wrong type报错
- 用系统时间做版本管理
- timeval和timespec转换
- 6、原理图设计
- 基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构---权限管理系统
- 7、板子形状剪切
- 手机网络判断
- 基于深度学习的目标检测研究进展
- Android传感器 设备坐标系到世界坐标系的转换 分析以及应用