SAP HANA插入表中,从计算视图中选择失败

时间:2018-06-15 09:10:34

标签: runtime-error hana insert-into

系统SAP HANA 1 SPS 12:1.00.112.16.1520578817

以下SQL失败:

drop table #my_new_table;

create local temporary column table #my_new_table (
    "AMPEL" varchar(5000),
    "ReportingLevel0" varchar(5000) , 
    "ReportingLevel1" varchar(255), 
    "ReportingLevel2" varchar(255), 
    "PosStatus" varchar(255), 
    "DirtyValue" double, 
    "DirtyValueT0" double,
    "FullPL" double, 
    "CashPL" double, 
    "UniqueID" varchar(255), 
    "CHECK_ID" BIGINT , 
    "NAME" varchar(255), 
    "CT" varchar(255), 
    "CT_ERGEBNIS_UNIQUE_ID" BIGINT , 
    "RUN_ID" BIGINT 
);

truncate table #my_new_table;
insert into #my_new_table (ampel, "ReportingLevel0")
select ampel, "ReportingLevel0" from (
SELECT 
    CASE WHEN "CT_ERGEBNIS_UNIQUE_ID" IS NULL THEN 0 ELSE 8 END as "AMPEL", 
    "ReportingLevel0", "ReportingLevel1", "ReportingLevel2", "PosStatus", "DirtyValue", "DirtyValueT0",
    "FullPL", "CashPL", "UniqueID", "CHECK_ID", b."NAME", "CT", "CT_ERGEBNIS_UNIQUE_ID", "RUN_ID" 
FROM "_SYS_BIC"."xxx.dataset/PnL_Dataset"(
        PLACEHOLDER."$$jobId1$$" => 'XXXD401B-EA88-48DA-9EE6-CAE688440XXX', 
        PLACEHOLDER."$$jobId2$$" => 'XXXACBEA-5CE9-4661-AB19-654A66DD8XXX', 
        PLACEHOLDER."$$relevantJob$$" => 'XXXD401B-EA88-48DA-9EE6-CAE688440XXX') a 
    LEFT JOIN ( 
        SELECT * FROM "_SYS_BIC"."meag.app.h4q.checks/READ_JOIN_ATT_FROM_CHECK_RESULTS" 
        WHERE CHECK_ID IN ( 
            SELECT "CHECK_ID.CHECK_ID" 
            FROM     "MEAG_APP_H4Q_METADATA_001"."meag.app.h4q.metadata::DB.CHECK_TEMPLATE" 
            WHERE "DATENSEGMENT_ID.DATENSEGMENT_ID" = 7) 
                AND targetdate = ( 
                    SELECT DISTINCT a."DueDate" 
                    FROM "MEAG_EIM_TQL_001_TARGET"."TG_dbo_T_Job" a 
                        join     "MEAG_EIM_TQL_001_TARGET"."TG_dbo_T_PL_Instrument" b on b."JobId" = a."JobId" 
                    WHERE a."JobId" = '6BCD401B-EA88-48DA-9EE6-CAE688440A3C'
               ) AND ( targetjobid = 'XXXD401B-EA88-48DA-9EE6-CAE688440XXX' OR targetjobid = '') 
) b ON a."T_SCD_Instrument_RH_WPID" = b.WPID AND a."T_SCD_Instrument_RH_LegNo" = b."LegNo" 
) ;

错误消息是:

Could not execute 'insert into #my_new_table (ampel, "ReportingLevel0") SELECT CASE WHEN "CT_ERGEBNIS_UNIQUE_ID" IS ...'
SAP DBTech JDBC: [269]: too many values: ReportingLevel1: line 4 col 21 (at pos 158)

1 个答案:

答案 0 :(得分:0)

错误消息错误/误导。

问题是列视图Column ReportingLevel1的定义是varchar(16)。

从视图中选择没有任何问题。

同样选择上述表中的不同。

在计算视图中将列更改为varchar(36)会将insert插入到语句