简体   繁体   English

SSIS 使用参数映射执行 SQL 任务多步骤

[英]SSIS Execute SQL Task multi step with parameter mapping

I have a DTSX file that has an update statement that is selecting from itself in the update statement and it is filling up the temp DB.我有一个 DTSX 文件,它有一个更新语句,它在更新语句中从自身中进行选择,并且它正在填充临时数据库。 It is using parameter mapping for a variable in the update statement.它对更新语句中的变量使用参数映射。

I rewrote it to first run the select statement into a temp table and then run the update statement, but I get the following error "Multiple-step OLE DB operation generated errors..."我重写了它,首先将select语句运行到临时表中,然后运行更新语句,但出现以下错误“多步OLE DB操作生成错误...”

I am not very familiar with SSIS packages and am wondering if I have written the statement incorrectly.我对 SSIS 包不是很熟悉,想知道我是否写错了语句。

Below is the query.下面是查询。 Notice the update statement at the bottom has the "?"注意底部的更新语句有“?” in it, which I thought would get the parameter mapped to it.在其中,我认为可以将参数映射到它。

if OBJECT_ID(N'tempdb..#QUERYCF') is not null
  drop table #QUERYCF
go

select
        cafi_key,
        newfrequency.fr_key as cafi_freqkey,
        newcarriercharge.cacr_key as cafi_carrierchargekey,
        newcarrierrate.cara_key as cafi_carrierratekey
INTO #QUERYCF
    from stg_fct_carrierfinancial
    left outer join fin_dim_date chargedate
        on cafi_chargedtkey = chargedate.dt_key

    inner join fin_dim_carriercharge currentcarriercharge
        on cafi_carrierchargekey = currentcarriercharge.cacr_key
    inner join lkp_dim_carriercharge newcarriercharge
        on currentcarriercharge.cacr_db_code = newcarriercharge.cacr_db_code
        and currentcarriercharge.cacr_code = newcarriercharge.cacr_code
        and chargedate.dt_epochday between newcarriercharge.cacr_stdt_epochday and newcarriercharge.cacr_endt_epochday

    inner join fin_dim_frequency currentfrequency
        on cafi_freqkey = currentfrequency.fr_key
    inner join lkp_dim_frequency newfrequency
        on currentfrequency.fr_db_code = newfrequency.fr_db_code
        and currentfrequency.fr_pu_code = newfrequency.fr_pu_code
        and currentfrequency.fr_code = newfrequency.fr_code
        and chargedate.dt_epochday between newfrequency.fr_stdt_epochday and newfrequency.fr_endt_epochday

    inner join fin_dim_carrierrate currentcarrierrate
        on cafi_carrierratekey = currentcarrierrate.cara_key
    inner join lkp_dim_carrierrate newcarrierrate
        on currentcarrierrate.cara_db_code = newcarrierrate.cara_db_code
        and currentcarrierrate.cara_code = newcarrierrate.cara_code
        and chargedate.dt_epochday between newcarrierrate.cara_stdt_epochday and newcarrierrate.cara_endt_epochday

    where cafi_deleteloadkey is null and
    (
        currentcarriercharge.cacr_mostrecentcode = 0 or
        currentfrequency.fr_mostrecentcode = 0
    )

GO



update stg_fct_carrierfinancial
    set cafi_freqkey = newdata.cafi_freqkey,
    cafi_carrierchargekey = newdata.cafi_carrierchargekey,
    cafi_carrierratekey = newdata.cafi_carrierratekey,
    cafi_modifyloadkey = ?
from stg_fct_carrierfinancial currentdata
inner join (select
        cafi_key,
        cafi_freqkey,
        cafi_carrierchargekey,
        cafi_carrierratekey
FROM #QUERYCF
) newdata
on currentdata.cafi_key = newdata.cafi_key

GO

drop table #QUERYCF
GO

Here is the full error message:这是完整的错误消息:

Build Facts (8/30/2019 10:40:25 PM)构建事实 (8/30/2019 10:40:25 PM)

Message: ExecutionID: Failure Code #-4001Source: Update obseleted dim keys in stg_fct_carrierfinancial SubComponent: Execute SQL Task ErrorCode: -1073548784 Description: Executing the query "消息:ExecutionID:失败代码 #-4001 来源:更新 stg_fct_carrierfi​​nancial 子组件中已废弃的昏暗键:执行 SQL 任务错误代码:-1073548784 描述:执行查询“

select cafi_key, newfrequency.fr_key as cafi_..." failed with the following error: "Multiple-step OLE DB operation generated errors. select cafi_key, newfrequency.fr_key as cafi_...”失败并出现以下错误:“多步 OLE DB 操作生成错误。 Check each OLE DB status value, if available.检查每个 OLE DB 状态值(如果可用)。 No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.未完成任何工作。”。可能的失败原因:查询问题、“ResultSet”属性设置不正确、参数设置不正确或连接未正确建立。

Source: Update obseleted keys in stg_fct_startstoprestarttrans SubComponent: Execute SQL Task ErrorCode: -1073548784 Description: Executing the query "来源:更新 stg_fct_startstoprestarttrans 子组件中已废弃的键:执行 SQL 任务错误代码:-1073548784 说明:正在执行查询“

select stsprstr_key, newfrequency.fr_key as s..." failed with the following error: "Multiple-step OLE DB operation generated errors. select stsprstr_key, newfrequency.fr_key as s...”失败并出现以下错误:“多步 OLE DB 操作生成错误。 Check each OLE DB status value, if available.检查每个 OLE DB 状态值(如果可用)。 No work was done.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.未完成任何工作。”。可能的失败原因:查询问题、“ResultSet”属性设置不正确、参数设置不正确或连接未正确建立。

Elapsed Time: 7800 secs Elapsed Time: 02:09:59 Return Code: -4001 (SSIS_EXECUTE_FAILURE)已用时间:7800 秒已用时间:02:09:59 返回代码:-4001 (SSIS_EXECUTE_FAILURE)

I think that the main problem is caused by aliases, since you have given currentdata as alias to stg_fct_carrierfinancial in the FROM clause, but you didn't use it in the UPDATE clause.我认为主要问题是由别名引起的,因为您在 FROM 子句stg_fct_carrierfinancial currentdata作为stg_fct_carrierfinancial别名,但您没有在 UPDATE 子句中使用它。

Try using the following query:尝试使用以下查询:

update currentdata
    set currentdata.cafi_freqkey = newdata.cafi_freqkey,
    currentdata.cafi_carrierchargekey = newdata.cafi_carrierchargekey,
    currentdata.cafi_carrierratekey = newdata.cafi_carrierratekey,
    currentdata.cafi_modifyloadkey = ?
from stg_fct_carrierfinancial currentdata 
inner join (select
        cafi_key,
        cafi_freqkey,
        cafi_carrierchargekey,
        cafi_carrierratekey
FROM #QUERYCF
) newdata
on currentdata.cafi_key = newdata.cafi_key

GO

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM