码迷,mamicode.com
首页 > 数据库 > 详细

SSISDB5:Parameter

时间:2016-05-18 21:34:28      阅读:311      评论:0      收藏:0      [点我收藏+]

标签:

Parameter 是Package 给外部提供的接口,通过修改Parameter,能够控制Package执行的属性,产生不同的结果。Parameter 有三种值:design_default_value,Default_Value 和 Execution_Value。

1,design_default_value是project 部署前,designer 设置的parameter的默认值。

2,Default_Value 是project 部署到SSISDB后,Parameters的默认值,如果不对Parameters进行修改,Default_Value  和 design_default_value是相同的。可以在Integration Services Catalog中,选中Project->右击Configure,修改Parameters的Default_Value。

3,Execution_Value是package 执行时,Package parameters的值。可以在Integration Services Catalog中,选中Project->package,右击Execute,将Parameters 的 Default_Value修改为此次执行的参数值。

4,Parameter 还可以引用Environment 中的 Variables。

参数的属性

Sensitive 是parameter的敏感性,对于敏感参数,SSIS对值进行加密

Required是Parameter的必需性,对于必需参数,在执行时,必须设置值;在Create Agent执行Package,必须显示必需参数的值。

技术分享

一,在SSISDB中,从 [catalog].[object_parameters] 和 [catalog].[execution_parameter_values] 中查看 package的这三种参数值。

--object_type : 20 (project parameter), 30 (package parameter)
--value_type: V (parameter_value is a literal value),R(referencing an environment variable)
--value_set:1(the parameter value has been assigned), 0 (the parameter value has not been assigned)

select op.project_id,p.name as ProjectName,
    op.object_type,        
    op.object_name,op.parameter_name,op.data_type,
    op.required,op.sensitive,
    op.design_default_value,op.default_value,
    op.value_type,op.referenced_variable_name,
    op.value_set
from [catalog].[object_parameters] op with(NOLOCK)
inner join catalog.projects p with(nolock)
    on op.project_id=p.project_id
where object_type in(20,30)

二,通过TSQL 来使用参数

declare @Execution_ID bigint
exec catalog.create_execution @package_name=NTest.dtsx,
    @Execution_ID=@Execution_ID output,
    @folder_name=NMyProjectFloder,
    @project_name=NMyProject,
    @use32bitruntime=FALSE,
    @reference_id=null

declare @var0 sql_variant=NPackage_Parameter_value;
exec catalog.set_execution_parameter_value 
    @Execution_ID=@Execution_ID,
    @object_type=30,        --Package
    @parameter_name=NPackage_Parameter_Name,
    @parameter_value=@var0

exec catalog.start_execution @Execution_ID=@Execution_ID

 

三,特殊参数

SSISDB的特殊参数,用于控制Package执行时的特殊行为,这些参数的值,通过 catalog.set_execution_parameter_value 来设置。

  • LOGGING_LEVEL

  • CUSTOMIZED_LOGGING_LEVEL

  • DUMP_ON_ERROR

  • DUMP_ON_EVENT

  • DUMP_EVENT_CODE

  • CALLER_INFO

  • SYNCHRONIZED

 LOGGING_LEVEL – Integer – 0 | 1* | 2 | 3 – Sets the logging level for this execution.  The values represent no logging, basic, performance, and verbose levels respectively.

SYNCHRONIZED - Boolean - 0 synchronous | 1 asynchronous

 

参考文档:《SSIS Parent-Child Architecture in Catalog Deployment Mode

First of all, by default when executing a package using T-SQL, the package is started asynchronously.  This means that when you call the stored procedure [SSISDB].[catalog].[start_execution], the T-SQL command will return immediately (assuming you passed in a valid package name and parameters), giving no indication of either success or failure.  That’s why, on this example, I’m setting the execution parameter named SYNCHRONIZED to force the T-SQL command to wait until the package has completed execution before returning.  (Note: For additional information about execution parameters, check out this post by Phil Brammer).  Second, regardless of whether you set the SYNCHRONIZED parameter, the T-SQL command will not return an error even if the package fails. 

DECLARE @execution_id BIGINT

EXEC [SSISDB].[catalog].[create_execution] @package_name = NChildPkgRemote.dtsx
    ,@execution_id = @execution_id OUTPUT
    ,@folder_name = NSSIS Parent-Child
    ,@project_name = NSSIS Parent-Child Catalog Deployment - Child
    ,@use32bitruntime = False
    ,@reference_id = NULL

-- Set user parameter value for filename
DECLARE @filename SQL_VARIANT = NE:\Dropbox\Presentations\_sampleData\USA_small1.txt

EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id
    ,@object_type = 30
    ,@parameter_name = NpSourceFileName
    ,@parameter_value = @filename

-- Set execution parameter for logging level
DECLARE @loggingLevel SMALLINT = 1

EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id
    ,@object_type = 50
    ,@parameter_name = NLOGGING_LEVEL
    ,@parameter_value = @loggingLevel

-- Set execution parameter for synchronized
DECLARE @synchronous SMALLINT = 1

EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id
    ,@object_type = 50
    ,@parameter_name = NSYNCHRONIZED
    ,@parameter_value = @synchronous

-- Now execute the package
EXEC [SSISDB].[catalog].[start_execution] @execution_id

-- Show status
SELECT [status] AS [execution_status]
FROM SSISDB.CATALOG.executions
WHERE execution_id = @execution_id

 

参考文档:

catalog.object_parameters (SSISDB Database)

catalog.set_execution_parameter_value (SSISDB Database)

Quick Tip – Run SSIS 2012 packages synchronously and other execution parameters

 

SSISDB5:Parameter

标签:

原文地址:http://www.cnblogs.com/ljhdo/p/5493125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!