简体   繁体   English

SSIS - 使用Attunity Oracle Datasource在Oracle Query中使用参数

[英]SSIS - Using parameters in Oracle Query using Attunity Oracle Datasource

I am using the Attunity Oracle connector in SSIS to connect to a remote Oracle Server. 我在SSIS中使用Attunity Oracle连接器连接到远程Oracle Server。

In my SSIS package, I need to connect to an Oracle database to fetch the data based on datetime parameters. 在我的SSIS包中,我需要连接到Oracle数据库以根据datetime参数获取数据。

I followed the suggestions here to write a SELECT query with a parameter: 我按照这里的建议写了一个带有参数的SELECT查询:

  1. Created a package variable 创建了一个包变量
  2. Set the variable to evaluate as expression true 将变量设置为计算为表达式true
  3. Put the query in expression along with parameter as a different package variable 将查询与表达式一起放在表达式中作为不同的包变量
  4. Set the expression for [Oracle Source].[SqlCommand] at Data Flow to package variable (containing the query as expression) 在数据流中将[Oracle Source].[SqlCommand]的表达式设置为包变量(包含查询作为表达式)

I am good up to here, but if you are setting an expression for [Oracle Source].[SqlCommand] at the Data Flow, then what Query do I set in the "Oracle Source" inside the Data Flow task? 我很高兴在这里,但是如果你在数据流中为[Oracle Source].[SqlCommand]设置表达式,那么我在数据流任务中的“Oracle Source”中设置了什么Query How do I get the output columns and perform transformations? 如何获取输出列并执行转换?

I am not able to execute the package until I set a valid Oracle data source. 在设置有效的Oracle数据源之前,我无法执行包。

Every recommendation says to set the [Oracle Source].[SqlCommand] property at the Data Flow, but nobody mentions how to configure the Oracle source. 每个建议都说在数据流中设置[Oracle Source].[SqlCommand]属性,但是没有人提到如何配置Oracle源代码。 Am I missing something here? 我在这里错过了什么吗?


Update (2014/02/18) - 更新(2014/02/18) -

Based on comments by @billinkc, I created the data source with non-parameter query and added the expression at the data flow. 基于@billinkc的评论,我使用非参数查询创建了数据源,并在数据流中添加了表达式。 When I execute the package, the query inside the data source changed to whatever is there in my package variable expression but it throws an error: 当我执行包时,数据源内的查询更改为我的包变量表达式中的任何内容,但它会引发错误:

OCI error encountered. 遇到OCI错误。 ORA-00936: missing expression ORA-00936:缺少表达

Here is my WHERE clause of the query, with the variable timestamp - 这是查询的WHERE子句,带有可变时间戳 -

Where SL.RECEIVED_DATE = TO_DATE( @[User::Last_Run_Timestamp] , 'dd/mon/yyyy HH24:MI:SS')

To parameterize with Attunity Oracle data source, you need to get your metadata set first. 要使用Attunity Oracle数据源进行参数化,您需要先获取元数据集。 This is usually done by just using the unparameterized query as the source. 这通常只需使用非参数化查询作为源来完成。 Then, in the Control Flow, on the Data Flow's Expressions you will sub in the SSIS Variable as a source. 然后,在控制流中,在数据流的表达式上,您将在SSIS变量中作为源。

It is important that your SSIS Variable be set with Evaluate as Expression set to true and then your formula must be created correctly. 使用Evaluate as Expression设置为true来设置SSIS变量非常重要,然后必须正确创建公式。 Unlike a PowerShell, the tokens are not replaced within in a string. 与PowerShell不同,令牌不会在字符串中替换。 Instead, you'll need to use classic string concatenation techniques. 相反,您需要使用经典的字符串连接技术。 The following demonstrates casting the Variable @[User::Last_Run_Timestamp] to a string which allows me to concatenate, via + , with the rest of my filter. 下面演示如何将Variable @[User::Last_Run_Timestamp]为一个字符串,该字符串允许我通过+与我的过滤器的其余部分连接。

"SELECT * FROM Table SL Where SL.RECEIVED_DATE = TO_DATE( " 
+ (DT_WSTR, 24)@[User::Last_Run_Timestamp] 
+ " , 'dd/mon/yyyy HH24:MI:SS')"

I just had to deal with this one. 我只需处理这个问题。 This is not very intuitive, but follow along... 这不是很直观,但请遵循......

  • On the Control Flow designer, right click on the Data Flow itself and open Properties. 在Control Flow设计器上,右键单击Data Flow本身并打开Properties。

  • Find 'Expressions' and click the ellipse to open the Expression Editor. 找到“表达式”并单击椭圆以打开表达式编辑器。

  • Under property, select [Oracle Source].[SqlCommand] and then you can build an expression. 在属性下,选择[Oracle Source]。[SqlCommand]然后您可以构建表达式。

More details: http://sornanara.blogspot.com/2013/11/ssis-use-dynamic-sql-in-oracle-source.html 更多细节: http//sornanara.blogspot.com/2013/11/ssis-use-dynamic-sql-in-oracle-source.html

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

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