oracle 用于数据流任务的 Foreach 循环容器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11008637/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 00:53:46  来源:igfitidea点击:

Foreach Loop Container For Data Flow Task

sqlsql-serveroraclessis

提问by Pratik

I want to import nearly 12 million records from oracle DB but beacuse of the SSIS memory buffer problem i need to iterate my Data Flow Task for each year i.e 2005 to 2012 (7 times). How can i use foreach my oracle query to fetch the data year wise.

我想从 oracle DB 导入近 1200 万条记录,但由于 SSIS 内存缓冲区问题,我需要每年迭代我的数据流任务,即 2005 年到 2012 年(7 次)。我如何使用 foreach 我的 oracle 查询来明智地获取数据。

Query

询问

SELECT * FROM EMP_RECORDS_DETAILS WHERE to_char(JOIN_DT,'YYYY')=2005

SELECT * FROM EMP_RECORDS_DETAILS WHERE to_char(JOIN_DT,'YYYY')=2005

回答by praveen

I have solved the above problem using Sql Server . So only thing which you need to change is the Select query

我已经使用 Sql Server 解决了上述问题。所以唯一需要改变的是 Select 查询

  1. First Create a variable to store the date for each year .

     Name: TimeValue  DataType=Int32
    
  2. Use a ForEach Loop and select Foreach Item enumerator in the collection tab

  1. 首先创建一个变量来存储每年的日期。

     Name: TimeValue  DataType=Int32
    
  2. 使用 ForEach 循环并在集合选项卡中选择 Foreach Item enumerator

New Column

新栏目

  1. Click on the Columns tab and create a new column of datatype int

  2. In the variable mapping map the variable created above .

  1. 单击列选项卡并创建一个数据类型为 int 的新列

  2. 在变量映射映射上面创建的变量。

Mapping

映射

  1. Inside the dataflow use an oledb destination and in the data access mode select sql command .The query in the where clause should be changed and try to select the columns instead of giving *.
  1. 在数据流内部使用 oledb 目标并在数据访问模式中选择 sql 命令。应更改 where 子句中的查询并尝试选择列而不是提供 *。

SQL Query

SQL查询

  1. Click on the parameters tab map the parameter created for the foreach loop
  1. 单击参数选项卡映射为 foreach 循环创建的参数

Mapping Paramters

映射参数

In case if the values of date are not known before then you can use execute sql task before foreach loop and select only the dateTime column values from the table and store it in a variable and in the foreach loop use Foreach from variable enumerator in the collection tab and select the variable created in the above execute sql task .

如果之前不知道日期的值,那么您可以在 foreach 循环之前使用 execute sql task 并仅从表中选择 dateTime 列值并将其存储在变量中,并在 foreach 循环中使用 Foreach from variable enumerator 在集合中选项卡并选择在上面执行 sql 任务中创建的变量。

Hope this helps u.

希望这对你有帮助。