ora-01858找到一个非数字字符,其中的数字应为预期的格式

时间:2019-12-16 12:25:40

标签: oracle informatica-powercenter

我在informatica 10.2.0中创建了一个非常简单的映射。每当我尝试执行工作流程时,会话任务就会失败。

错误如下,

Severity    Timestamp   Node    Thread  Message Code    Message
ERROR   16-12-2019 05:24:50 PM  node01_prdeim   READER_1_2_1    RR_4035 SQL Error [
ORA-01858: a non-numeric character was found where a numeric was expected

Database driver error...
Function Name : Execute
SQL Stmt : select MARKET_ID,MARKET_NAME,MONTH_YY,'Y' ACTUAL_FLAG  from TABLEAU_NEW_MARKET_COVERAGE
where 
TO_DATE(MONTH_YY)=TO_CHAR(TRUNC(ADD_MONTHS(SYSDATE,-1), 'MON'),'DD-MON-YYYY')
and OFMCG_SALES>667
Database driver error...
Function Name : Execute
SQL Stmt : select MARKET_ID,MARKET_NAME,MONTH_YY,'Y' ACTUAL_FLAG  from TABLEAU_NEW_MARKET_COVERAGE
where 
TO_DATE(MONTH_YY)=TO_CHAR(TRUNC(ADD_MONTHS(SYSDATE,-1), 'MON'),'DD-MON-YYYY')
and OFMCG_SALES>667].

源表结构

Name                   Null? Type          
---------------------- ----- ------------- 
BRANCH_CODE                  VARCHAR2(10)  
MARKET_NAME                  VARCHAR2(255) 
MARKET_ID                    NUMBER(12)    
MARKET_POP_GROUP             VARCHAR2(50)  
MONTH_YY                     DATE          
OFMCG_SALES                  NUMBER        
TYPE                         VARCHAR2(255) 
SERVICE_MODE                 VARCHAR2(255) 
SERVICE_FLAG                 VARCHAR2(255) 
QUALITY_MKT_TARGET           NUMBER        
QUALITY_MKT_UOB              NUMBER        
QUALITY_MARKET               VARCHAR2(26)  
CONCERN_MARKET               VARCHAR2(26)  
QUALITY_MKT_ACTUAL_UOB       NUMBER        
PLAN_FLG                     VARCHAR2(500) 

目标表结构,

Name         Null?    Type          
------------ -------- ------------- 
MARKET_ID    NOT NULL VARCHAR2(20)  
MARKET_NAME  NOT NULL VARCHAR2(200) 
WDCODE       NOT NULL VARCHAR2(20)  
POP_GROUP             VARCHAR2(50)  
DISTRICT              VARCHAR2(100) 
SUB_DISTRICT          VARCHAR2(100) 
PLAN_FLAG             VARCHAR2(20)  
ACTUAL_FLAG           VARCHAR2(20)  
TRANSDATE    NOT NULL DATE          
LASTUPDATE   NOT NULL NUMBER  

在我的源代码限定词中,sql重写为

select MARKET_ID,MARKET_NAME,MONTH_YY,'Y' ACTUAL_FLAG  from TABLEAU_NEW_MARKET_COVERAGE
where 
MONTH_YY=TO_CHAR(TRUNC(ADD_MONTHS(SYSDATE,-1), 'MON'),'DD-MON-YYYY')
and OFMCG_SALES>667

这是一个非常简单的映射,

SRC-EXP-JNR-UPD-TGT

试图查找错误详细信息。数据类型在informatica和oracle中都很好。

有人可以指导我导致问题的原因吗?

1 个答案:

答案 0 :(得分:1)

您的MONTH_YY是日期列,但您仍尝试将其转换为日期。

使用以下查询:

SELECT
    MARKET_ID,
    MARKET_NAME,
    MONTH_YY,
    'Y' ACTUAL_FLAG
FROM
    TABLEAU_NEW_MARKET_COVERAGE
WHERE
    TRUNC(MONTH_YY) = TRUNC(ADD_MONTHS(SYSDATE, - 1), 'MON') 
    -- used trunc for MONTH_YY
    -- removed to_char from right side expression
    AND OFMCG_SALES > 667

干杯!