views:

29

answers:

2

I have an Oracle source, and I'm getting the entire table, and it is being copied to a SQL Server 2008 table that looks the same. Just for testing, I would like to only get a subset of the table.

In the old DTS packages, under Options on the data transform, I could set a first and last record number, and it would only get that many records.

If I were doing a query, I could change it to a select top 5000 or set rowcount 5000 at the top (maybe? This is an Oracle source). But I'm grabbing the entire table.

How do I limit the rowcount when selecting an Oracle table?

A: 

Hi

We can use the rowcount component in the dataflow and after the component make User::rowCount <= 500 in the precedence constraint condition while loding into the target. Whenever the count >500 the process stops to inserts the data into the target table.

thanks

prav

praveen
Sorry, I thought in the control flow but actually in the data flow we can't set the precedence constraint condition. I will comeback with sample test.thanksprav
praveen
Ok, thoughts1. If we have source data PK in the numbers we can use that using the split condition.2. Create a derived table with one identity column and PK form surce then take top X records using the Lookup method.3. dumping complete source data into a derived table with same schema of the source then selecting X number of records to source.any more thoughts plea let me know.thanksprav
praveen
That sounds like a lot of work for just limiting the number during testing. I'll want all the data when I'm out of testing, but don't need all 4 million records now (nor do I want to wait for that to run).
thursdaysgeek
Hi, we could use the row sampling component in the data flow to restrict the number of rows required to transfer to target table and if we don't want any restrictions just we can take off the component from the data flow and direct map the target columns.I tested this method.I feel minimal work than previous thoughts.thanksprav
praveen
A: 

It's been a while since I've touched pl/sql, but I would think that you could simply put a where condition of "rownum <= n" where n = the number of rows that you want for your sample. ROWNUM is a pseudo-column that exists on each Oracle table . . . it's a handy feature for problems like this (it's equivalent to t-sql's row_number() function without the ability to partition and sort (I think). This would keep you from having to bring in the whole table into memory:

select col1, col2
from tableA
where rownum <= 10;

For future reference (and only because I've been working with it lately), DB2's equivalent for this is the clause "fetch first n only" at the end of the statement:

select col1, col2
from tableA
fetch first 10 only;

Hope I've not been too off base.

scottE
But, I'm not doing a query, I'm just grabbing the table. I can change it to a query, if necessary, but there are 20+ fields and I didn't want to identify each one.
thursdaysgeek