Showing posts with label rows. Show all posts
Showing posts with label rows. Show all posts

Thursday, March 22, 2012

Calculate values between previous rows

First, thanks to all of those that post to this newsgroup. You've
saved me tons of development time. I am trying to calculate values
between previous rows in my table. The table looks something like
this:
ID Value
1 100
2 200
3 300
4 400
5 ?
I was wondering if there was a way to create an expression that would
calculate the difference between row 4 and row 1. I am expecting row 5
to be 300. I have looked at the previous function, but this does not
seem to be what I am looking for. Any ideas?
Thank you,
Scott Leandro
scottleandro_@.gmail.com (remove the _)save row1 value into a variable and then subtract from it
i.e.
set @.myValue = select value from table where ID = 1
then
select id , value -@.myvalue
from xxx
you might have to work around your design so that value for ID =1 won't
return 0
ken
scottleandro@.gmail.com wrote:
> First, thanks to all of those that post to this newsgroup. You've
> saved me tons of development time. I am trying to calculate values
> between previous rows in my table. The table looks something like
> this:
> ID Value
> 1 100
> 2 200
> 3 300
> 4 400
> 5 ?
> I was wondering if there was a way to create an expression that would
> calculate the difference between row 4 and row 1. I am expecting row 5
> to be 300. I have looked at the previous function, but this does not
> seem to be what I am looking for. Any ideas?
> Thank you,
> Scott Leandro
> scottleandro_@.gmail.com (remove the _)|||SQLKen,
Thanks for the reply. I wish I could do this in a SP, but
unfortunately I have to to do this calculation in a RS table cell
expression.
Thanks,
Scott
SQLKen wrote:
> save row1 value into a variable and then subtract from it
> i.e.
> set @.myValue = select value from table where ID = 1
> then
> select id , value -@.myvalue
> from xxx
> you might have to work around your design so that value for ID =1 won't
> return 0
> ken
>
> scottleandro@.gmail.com wrote:
> > First, thanks to all of those that post to this newsgroup. You've
> > saved me tons of development time. I am trying to calculate values
> > between previous rows in my table. The table looks something like
> > this:
> >
> > ID Value
> > 1 100
> > 2 200
> > 3 300
> > 4 400
> > 5 ?
> >
> > I was wondering if there was a way to create an expression that would
> > calculate the difference between row 4 and row 1. I am expecting row 5
> > to be 300. I have looked at the previous function, but this does not
> > seem to be what I am looking for. Any ideas?
> >
> > Thank you,
> > Scott Leandro
> > scottleandro_@.gmail.com (remove the _)sql

Tuesday, March 20, 2012

Calculate difference between two rows

Hi,

i have a matrix, and in that matrix i need to have one column which calculates the percentage change between a value on the current row and the same value on the previous row.

Is this possible? The RunningValue() function isn't of help as it can't help me calculate the change between two rows, and Previous() doesn't work in a matrix (why?!!!!!). Also calculating this as part of the query isn't possible as there is a single row group on the matrix, and the query is MDX.*

Thanks,

sluggy

*for those who are curious, the matrix is showing data an a per week basis, the row group is snapshot date, i am trying to measure the change in sales at each snapshot.

Hi sluggy,

I Have the same problem now.

Have you found a solution?

Thanks

|||

I sure did. I used some custom code, on each row i called the function with the value from that row, and the function kept track of the previous values in an array.

If you can wait for about 24 hours from the time of this post, i will be able to post the function code for you.

|||Yes please send me the code.|||

Here you go....

think of this as measuring the change in booked theatre seats - i have the amount booked, and the capacity of the theatre. In the matrix field that contains the calculation, i have this as an expression:

=FormatPercent(

Code.CalcChangeInFill( Sum(Fields!Booked.Value), Sum(Fields!Capacity.Value), RowNumber("MyMatrix") ),

2,

true,

false,

true

)

and then in the code i have this:

Dim bookedVals() As Decimal

Dim capacityVals() As Decimal

Function CalcChangeInFill(ByVal bookedAmt As Decimal, ByVal capacityAmt As Decimal, ByVal rowNum as Integer) As Decimal

Dim upper As Integer

upper = 0

On Error Resume Next

If rowNum > 1 Then

upper = UBound(bookedVals) + 1

End If

ReDim Preserve bookedVals(upper)

bookedVals(upper) = bookedAmt

ReDim Preserve capacityVals(upper)

capacityVals(upper) = capacityAmt

If upper > 0 Then

If capacityVals(upper) = capacityVals(upper - 1) Then

If capacityVals(upper) = 0 Then

CalcChangeInFill = 0

Else

CalcChangeInFill = (bookedVals(upper) - bookedVals(upper - 1)) / capacityVals(upper)

End If

Else

If capacityVals(upper) = 0 Then

CalcChangeInFill = -100

ElseIf capacityVals(upper - 1) = 0 Then

CalcChangeInFill = 100

Else

CalcChangeInFill = (bookedVals(upper) / capacityVals(upper)) - (bookedVals(upper - 1) / capacityVals(upper - 1))

End If

End If

Else

CalcChangeInFill = 0

End If

End Function

This calculation got a little complicated because the capacity of the theatre could change (i.e. extra seats were added). I tracked the rowNum because this would indicate the start of a matrix when i had multiple matrices (i.e. i had a list control grouping by Week, so each matrix would have a week's worth of data in it, each row would represent one day of bookings) - at the start of each matrix the row number is 1, so i would know to "restart" the arrays and the calculation.

I hope this helps :)

|||any ideas on getting this to work on columns?

the columns in my matrix are calendar year with a sub-group that sums a couple of values. I need the percentage increase/decrease in these sums per year.

thnx in advance|||

Hi

i've just done this by creating a function that takes the current value in
the column and puts it into an array. The columns populate from left to right and
top to bottom.

So you simply need to put put in a check depending on the number of columns that
are there. I know its dynamic but I mean IE:

GROUP YEAR

InvoiceQty SupplyQty

xxxxx xxxxxxxx

When doing the calculation put a table next to matrix with the same groupings
and call a function to get the values from the array and do a calculation on them.

If i'm unclear just tell me what u need..

Gerhard Davids

|||

Hi Everyone,

I solved a similar issue by adding a new column to the matrix and using this expression to find the percentage of change from month to month.

=(Sum(Fields!TotalSales.Value)-(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value)))/(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value))

NOTE: matrix1_FiscalMonth is my row group name

To find the percentage of change take the “after” amount, minus the “before” amount and divide that result by the before amount. i.e.(60-50)/50 = 20%

Regard,

AA

"Small things done consistently in strategic places create major impact"

Calculate difference between two rows

Hi,

i have a matrix, and in that matrix i need to have one column which calculates the percentage change between a value on the current row and the same value on the previous row.

Is this possible? The RunningValue() function isn't of help as it can't help me calculate the change between two rows, and Previous() doesn't work in a matrix (why?!!!!!). Also calculating this as part of the query isn't possible as there is a single row group on the matrix, and the query is MDX.*

Thanks,

sluggy

*for those who are curious, the matrix is showing data an a per week basis, the row group is snapshot date, i am trying to measure the change in sales at each snapshot.

Hi sluggy,

I Have the same problem now.

Have you found a solution?

Thanks

|||

I sure did. I used some custom code, on each row i called the function with the value from that row, and the function kept track of the previous values in an array.

If you can wait for about 24 hours from the time of this post, i will be able to post the function code for you.

|||Yes please send me the code.|||

Here you go....

think of this as measuring the change in booked theatre seats - i have the amount booked, and the capacity of the theatre. In the matrix field that contains the calculation, i have this as an expression:

=FormatPercent(

Code.CalcChangeInFill( Sum(Fields!Booked.Value), Sum(Fields!Capacity.Value), RowNumber("MyMatrix") ),

2,

true,

false,

true

)

and then in the code i have this:

Dim bookedVals() As Decimal

Dim capacityVals() As Decimal

Function CalcChangeInFill(ByVal bookedAmt As Decimal, ByVal capacityAmt As Decimal, ByVal rowNum as Integer) As Decimal

Dim upper As Integer

upper = 0

On Error Resume Next

If rowNum > 1 Then

upper = UBound(bookedVals) + 1

End If

ReDim Preserve bookedVals(upper)

bookedVals(upper) = bookedAmt

ReDim Preserve capacityVals(upper)

capacityVals(upper) = capacityAmt

If upper > 0 Then

If capacityVals(upper) = capacityVals(upper - 1) Then

If capacityVals(upper) = 0 Then

CalcChangeInFill = 0

Else

CalcChangeInFill = (bookedVals(upper) - bookedVals(upper - 1)) / capacityVals(upper)

End If

Else

If capacityVals(upper) = 0 Then

CalcChangeInFill = -100

ElseIf capacityVals(upper - 1) = 0 Then

CalcChangeInFill = 100

Else

CalcChangeInFill = (bookedVals(upper) / capacityVals(upper)) - (bookedVals(upper - 1) / capacityVals(upper - 1))

End If

End If

Else

CalcChangeInFill = 0

End If

End Function

This calculation got a little complicated because the capacity of the theatre could change (i.e. extra seats were added). I tracked the rowNum because this would indicate the start of a matrix when i had multiple matrices (i.e. i had a list control grouping by Week, so each matrix would have a week's worth of data in it, each row would represent one day of bookings) - at the start of each matrix the row number is 1, so i would know to "restart" the arrays and the calculation.

I hope this helps :)

|||any ideas on getting this to work on columns?

the columns in my matrix are calendar year with a sub-group that sums a couple of values. I need the percentage increase/decrease in these sums per year.

thnx in advance

|||

Hi

i've just done this by creating a function that takes the current value in
the column and puts it into an array. The columns populate from left to right and
top to bottom.

So you simply need to put put in a check depending on the number of columns that
are there. I know its dynamic but I mean IE:

GROUP YEAR

InvoiceQty SupplyQty

xxxxx xxxxxxxx

When doing the calculation put a table next to matrix with the same groupings
and call a function to get the values from the array and do a calculation on them.

If i'm unclear just tell me what u need..

Gerhard Davids

|||

Hi Everyone,

I solved a similar issue by adding a new column to the matrix and using this expression to find the percentage of change from month to month.

=(Sum(Fields!TotalSales.Value)-(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value)))/(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value))

NOTE: matrix1_FiscalMonth is my row group name

To find the percentage of change take the “after” amount, minus the “before” amount and divide that result by the before amount. i.e.(60-50)/50 = 20%

Regard,

AA

"Small things done consistently in strategic places create major impact"

Calculate difference between two rows

Hi,

i have a matrix, and in that matrix i need to have one column which calculates the percentage change between a value on the current row and the same value on the previous row.

Is this possible? The RunningValue() function isn't of help as it can't help me calculate the change between two rows, and Previous() doesn't work in a matrix (why?!!!!!). Also calculating this as part of the query isn't possible as there is a single row group on the matrix, and the query is MDX.*

Thanks,

sluggy

*for those who are curious, the matrix is showing data an a per week basis, the row group is snapshot date, i am trying to measure the change in sales at each snapshot.

Hi sluggy,

I Have the same problem now.

Have you found a solution?

Thanks

|||

I sure did. I used some custom code, on each row i called the function with the value from that row, and the function kept track of the previous values in an array.

If you can wait for about 24 hours from the time of this post, i will be able to post the function code for you.

|||Yes please send me the code.|||

Here you go....

think of this as measuring the change in booked theatre seats - i have the amount booked, and the capacity of the theatre. In the matrix field that contains the calculation, i have this as an expression:

=FormatPercent(

Code.CalcChangeInFill( Sum(Fields!Booked.Value), Sum(Fields!Capacity.Value), RowNumber("MyMatrix") ),

2,

true,

false,

true

)

and then in the code i have this:

Dim bookedVals() As Decimal

Dim capacityVals() As Decimal

Function CalcChangeInFill(ByVal bookedAmt As Decimal, ByVal capacityAmt As Decimal, ByVal rowNum as Integer) As Decimal

Dim upper As Integer

upper = 0

On Error Resume Next

If rowNum > 1 Then

upper = UBound(bookedVals) + 1

End If

ReDim Preserve bookedVals(upper)

bookedVals(upper) = bookedAmt

ReDim Preserve capacityVals(upper)

capacityVals(upper) = capacityAmt

If upper > 0 Then

If capacityVals(upper) = capacityVals(upper - 1) Then

If capacityVals(upper) = 0 Then

CalcChangeInFill = 0

Else

CalcChangeInFill = (bookedVals(upper) - bookedVals(upper - 1)) / capacityVals(upper)

End If

Else

If capacityVals(upper) = 0 Then

CalcChangeInFill = -100

ElseIf capacityVals(upper - 1) = 0 Then

CalcChangeInFill = 100

Else

CalcChangeInFill = (bookedVals(upper) / capacityVals(upper)) - (bookedVals(upper - 1) / capacityVals(upper - 1))

End If

End If

Else

CalcChangeInFill = 0

End If

End Function

This calculation got a little complicated because the capacity of the theatre could change (i.e. extra seats were added). I tracked the rowNum because this would indicate the start of a matrix when i had multiple matrices (i.e. i had a list control grouping by Week, so each matrix would have a week's worth of data in it, each row would represent one day of bookings) - at the start of each matrix the row number is 1, so i would know to "restart" the arrays and the calculation.

I hope this helps :)

|||any ideas on getting this to work on columns?

the columns in my matrix are calendar year with a sub-group that sums a couple of values. I need the percentage increase/decrease in these sums per year.

thnx in advance

|||

Hi

i've just done this by creating a function that takes the current value in
the column and puts it into an array. The columns populate from left to right and
top to bottom.

So you simply need to put put in a check depending on the number of columns that
are there. I know its dynamic but I mean IE:

GROUP YEAR

InvoiceQty SupplyQty

xxxxx xxxxxxxx

When doing the calculation put a table next to matrix with the same groupings
and call a function to get the values from the array and do a calculation on them.

If i'm unclear just tell me what u need..

Gerhard Davids

|||

Hi Everyone,

I solved a similar issue by adding a new column to the matrix and using this expression to find the percentage of change from month to month.

=(Sum(Fields!TotalSales.Value)-(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value)))/(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value))

NOTE: matrix1_FiscalMonth is my row group name

To find the percentage of change take the “after” amount, minus the “before” amount and divide that result by the before amount. i.e.(60-50)/50 = 20%

Regard,

AA

"Small things done consistently in strategic places create major impact"

|||Hi,

I am also facing same problem...do u got any solution....
plz help mesql

Calculate difference between two rows

Hi,

i have a matrix, and in that matrix i need to have one column which calculates the percentage change between a value on the current row and the same value on the previous row.

Is this possible? The RunningValue() function isn't of help as it can't help me calculate the change between two rows, and Previous() doesn't work in a matrix (why?!!!!!). Also calculating this as part of the query isn't possible as there is a single row group on the matrix, and the query is MDX.*

Thanks,

sluggy

*for those who are curious, the matrix is showing data an a per week basis, the row group is snapshot date, i am trying to measure the change in sales at each snapshot.

Hi sluggy,

I Have the same problem now.

Have you found a solution?

Thanks

|||

I sure did. I used some custom code, on each row i called the function with the value from that row, and the function kept track of the previous values in an array.

If you can wait for about 24 hours from the time of this post, i will be able to post the function code for you.

|||Yes please send me the code.|||

Here you go....

think of this as measuring the change in booked theatre seats - i have the amount booked, and the capacity of the theatre. In the matrix field that contains the calculation, i have this as an expression:

=FormatPercent(

Code.CalcChangeInFill( Sum(Fields!Booked.Value), Sum(Fields!Capacity.Value), RowNumber("MyMatrix") ),

2,

true,

false,

true

)

and then in the code i have this:

Dim bookedVals() As Decimal

Dim capacityVals() As Decimal

Function CalcChangeInFill(ByVal bookedAmt As Decimal, ByVal capacityAmt As Decimal, ByVal rowNum as Integer) As Decimal

Dim upper As Integer

upper = 0

On Error Resume Next

If rowNum > 1 Then

upper = UBound(bookedVals) + 1

End If

ReDim Preserve bookedVals(upper)

bookedVals(upper) = bookedAmt

ReDim Preserve capacityVals(upper)

capacityVals(upper) = capacityAmt

If upper > 0 Then

If capacityVals(upper) = capacityVals(upper - 1) Then

If capacityVals(upper) = 0 Then

CalcChangeInFill = 0

Else

CalcChangeInFill = (bookedVals(upper) - bookedVals(upper - 1)) / capacityVals(upper)

End If

Else

If capacityVals(upper) = 0 Then

CalcChangeInFill = -100

ElseIf capacityVals(upper - 1) = 0 Then

CalcChangeInFill = 100

Else

CalcChangeInFill = (bookedVals(upper) / capacityVals(upper)) - (bookedVals(upper - 1) / capacityVals(upper - 1))

End If

End If

Else

CalcChangeInFill = 0

End If

End Function

This calculation got a little complicated because the capacity of the theatre could change (i.e. extra seats were added). I tracked the rowNum because this would indicate the start of a matrix when i had multiple matrices (i.e. i had a list control grouping by Week, so each matrix would have a week's worth of data in it, each row would represent one day of bookings) - at the start of each matrix the row number is 1, so i would know to "restart" the arrays and the calculation.

I hope this helps :)

|||any ideas on getting this to work on columns?

the columns in my matrix are calendar year with a sub-group that sums a couple of values. I need the percentage increase/decrease in these sums per year.

thnx in advance|||

Hi

i've just done this by creating a function that takes the current value in
the column and puts it into an array. The columns populate from left to right and
top to bottom.

So you simply need to put put in a check depending on the number of columns that
are there. I know its dynamic but I mean IE:

GROUP YEAR

InvoiceQty SupplyQty

xxxxx xxxxxxxx

When doing the calculation put a table next to matrix with the same groupings
and call a function to get the values from the array and do a calculation on them.

If i'm unclear just tell me what u need..

Gerhard Davids

|||

Hi Everyone,

I solved a similar issue by adding a new column to the matrix and using this expression to find the percentage of change from month to month.

=(Sum(Fields!TotalSales.Value)-(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value)))/(SUM(Fields!TotalSales.Value,"matrix1_FiscalMonth")-Sum(Fields!TotalSales.Value))

NOTE: matrix1_FiscalMonth is my row group name

To find the percentage of change take the “after” amount, minus the “before” amount and divide that result by the before amount. i.e.(60-50)/50 = 20%

Regard,

AA

"Small things done consistently in strategic places create major impact"

calculate difference between rows (was "Sql")

Hi all,
If I have the table:

Date/Time DeviceNumber X
2/12/04 07:15:15 40 20
2/12/04 12:10:02 40 60
2/12/04 17:56:03 40 100
3/12/04 06:12:24 40 500
3/12/04 08:19:15 40 700

How I can calculate the difference of X where the first X was at the minimum time in 3/12/04 and the second X was at the minimum time in 2/12/04.

I mean the two rows:
3/12/04 06:12:24 40 500
2/12/04 07:15:15 40 20

The X difference is: 480

Please help
Thanks...Is it me, or does this seem like deja vu.

Try:

Select sum(xx)
from(
select x as xx
from table
where Date/Time = (select max(Date/Time) from table)
union
select multiply(x,-1) as xx
from table
where Date/Time = (select min(Date/Time) from table)
)

The syntax will have to be modified to fit your DBMS and correct any errors i may have included.|||Is it me, or does this seem like deja vu.
Yes, this question does seem to be posted on a daily basis at the moment!|||Is it me, or does this seem like deja vu.As George Carlin put it, "It's not just Deja Vu, it is Deja Vu all over again!"

-PatP

Sunday, March 11, 2012

Cal Measure % against total

How to define calculated member whose value should be the row value divided by total of all rows. Example, sales of 2005 was 50k and sales for 2006 was 100k. The % 2005 sales is 33% of total (150k) and 2006 is 67%.

Hi

For example to get the percentage of the Unit Sales for one customer of all customers, you write:

[Measures].[Unit Sales] / ([Measures].[Unit Sales], [Customers].[All Customers])

The key is, to divide by a MDX tuple ([Measures].[Unit Sales], [Customers].[All Customers]) which brings the value for all customers.

Hans

|||

Thank Hans

This problem is solved. Please guide me to get the same result with multiple dimensions.

Also, i have a variance calculated member, which is on the date time diminsion [Sale of 2005] - [Sale of 2006] = [Variance 2005]. I would like to see three measures, [Year 2005 Sale], [Year 2006 Sale] and variance. But i get Sales and variance figure under Year 2005 and same under Year 2006. How to get the desired result.

Thanks

Shekhar

|||

Hi Shekhar,

I'm not sure, if I did understand you right, but I think it's because your [Variance] is on the Time Dimension. I do it in my projects so, that I create a calculated member like:

MEMBER [Measures].[Year variance] AS ([Measures].[Unit Sales],[Time].Currentmember.Prevmember) - [Measures].[Unit Sales]

If Currentmember is Year 2007, den Prevmember is Year 2006 and so on.

If you use now all 3 in a select, you can see it "flat"

select

{ [Measures].[Year 2005 Sales], [Measures].[Year 2006 Sale], [Measures].[Year variance]} on columns,

.....

Hans

Thursday, March 8, 2012

CacheType in Lookup for Oracle OLEDB connection

Hi,

1. If I have millions of rows to be compared, then which cache type is prefereed for lookup, Partial or no caching?

2. If I have lookup connected to Oracle Oledb, cache type as partial and SqlCommandParam as following

select * from (SELECT ORDER_ID, OPER_KEY, STEP_KEY, SUM(OCCUR_COUNT) AS OCCUR_COUNT FROM SFWID_OPER_DESC_EXPLD GROUP BY ORDER_ID, OPER_KEY, STEP_KEY) refTable where refTable.ORDER_ID = ? and refTable.OPER_KEY = ? and refTable.STEP_KEY = ?

then it doesn't allow me to add the parameters from Advance tab of Lookup transformation edition, and raises following error

"Provider cannot derive parameter information and SetParametInfo has not been called"

what am I missing?

1. Depends on the amount of memory available and the size of the data set to be cached. A million of rows should not be a big deal; but you do the math; find the size of the row(using just the required columns) and multiply by the number of rows. You should provide a query instead selecting the table from the drop down list.

2. In SSIS mapping parameters in a half-way complex query is some times impossible. So try re-writing the query in a simpler way (perhaps creating a view). BTW, if you parametrize the query; then only partial cache will be used; meaning the query will be executed for every row in the pipeline, affecting negatively the performance of the package

|||

Rafael,

Is it possible that we dont define parameterized query for partial cache?

I had done following things:

For the partial caching, I have checked Enable memory restriction and Enable caching and has set the cache size. I have not checked "Modify sql statement" option. But, "SqlCommandParam" in advanced editor shows the query as follows:

select * from
(SELECT ORDER_ID, OPER_KEY, STEP_KEY, SUM(OCCUR_COUNT) AS OCCUR_COUNT FROM SFWID_OPER_DESC_EXPLD GROUP BY ORDER_ID, OPER_KEY, STEP_KEY) as refTable where [refTable].[ORDER_ID] = ? and [refTable].[OPER_KEY] = ? and [refTable].[STEP_KEY] = ?

But as this is not the perfect syntax for oracle, it showed the error. Thats why I have changed this query to following

select * from (SELECT ORDER_ID, OPER_KEY, STEP_KEY, SUM(OCCUR_COUNT) AS OCCUR_COUNT FROM SFWID_OPER_DESC_EXPLD GROUP BY ORDER_ID, OPER_KEY, STEP_KEY) refTable where refTable.ORDER_ID = ? and refTable.OPER_KEY = ? and refTable.STEP_KEY = ?

Now after the change, running the package throws the following error at this lookup

Error: An OLE DB error has occurred. Error code: 0x80040E5D. An OLE DB record is available. Source: "Microsoft OLE DB Provider for Oracle" Hresult: 0x80040E5D Description: "Parameter name is unrecognized.".

So, I went to advanced tab and checked "Modify sql statement" option but it doesnt allow me to add the parameter and throws the error as said in my earlier post.

|||

Is there any special reason for using partial cache? for performance reasons I would not recommned it; but in some cases it is necessary.

*I think* when you use partial cache the lookup uses a query w/parameters; so I don't think you have control over that. I know SSIS parameter mapping and Oracle are not very easy to get working; and I don't know how easy or possible is that in a Lookup transformtion. Search this forum for 'Oracle parameters' to see if you can find somthing helpful.

|||

I searched but couldn't find anything useful. Is it so that Lookup caching doesn't support Oracle parameters ?

Thanks,

Pratibha

|||

Hi Pratibha:

Did you find anything on using parameters in lookups for Oracle OLEDB. Please let me know if you have any workaround. I am also stuck in the same problem.

Any help will be greatly appreciated.

Thanks,

Vipul

Sunday, February 19, 2012

C# and SQL Server 2005, Same Query Different Results (More Rows)

Hi,

I execute this query in SQL Server 2005 Management Studio:

SELECT c.id, c.clientname
FROM NFClients AS c INNER JOIN
NFExportGroups AS eg ON eg.cid = c.id INNER JOIN
NFExportGroupInfo AS ei ON ei.exportid = eg.exportid
WHERE (ei.meterid = 4938) AND (NOT (eg.emailgroup IS NULL))

I get one row returned and it is correct.

Then I go to Visual Studio 2005, to my C-Sharp application, and I use the same query to populate two indexes of 'rowvalues', my trusty two-dimensional string array:

Code Snippet

SqlCommand sqlcmdExx = new SqlCommand("SELECT c.id, c.clientname from NFClients AS c INNER JOIN " +

"NFExportGroups AS eg ON eg.cid = c.id INNER JOIN NFExportGroupInfo AS ei ON ei.exportid = eg.exportid " +

"WHERE (ei.meterid = " + comparedgroupids[i, 2].ToString() + ") AND (NOT (eg.emailgroup IS NULL))", sqlconnBuildDataGridViewSet);

SqlDataReader sqldrExx = sqlcmdExx.ExecuteReader();

while (sqldrExx.Read())

{

rowvalues[i, 2] = sqldrExx.GetValue(1).ToString();

rowvalues[i, 3] = sqldrExx.GetValue(0).ToString();

}

sqldrExx.Close();

This time, the SqlDataReader picks up two rows, and the second one, with a different c.id and c.clientname does have a NULL value for eg.emailgroup. I have verified that the value of comparedgroupids[i, 2] is 4938, and I have also confirmed that sqlcmdExx.CommandText is exactly the same as the query I run in the SQL Server Management Studio. Why do I get different results with same query on the same database?

Thanks.

Dale

I'm not sure as to the cause of the difference but try using "(eg.mailgroup IS NOT NULL)" instead of (NOT (eg.emailgroup IS NULL))|||

Hi,

Found out this morning it was my mistake, I was looking at the wrong copy of the database. Sorry about that.

Dale

Thursday, February 16, 2012

bypass script component

is it possible to have the script component read X number of rows and then tell it don't read anymore, just pass this X number of rows to the destination?

Yes, sort of. Create two outputs on your script component, one for rows to keep and one to throw away. Then use the DirectRow to send them down the keep or throw away output.

You cannot stop the data flow, and prevent whatever source from reading more, you kind of filter then to an empty output.

|||

i was hoping there is a way to stop the source from reading but you've answered my question, you can't.

Thanks!

|||

Thanh Duong wrote:

i was hoping there is a way to stop the source from reading but you've answered my question, you can't.

Thanks!

Also be aware that if you use an asynch script component you don't have to divert the rows. If you don't do anything with them then they just disappear.

Performance-wise you might still be best doing this synchronously though.

All discussed here:

Select Top N in a data-flow
(http://blogs.conchango.com/jamiethomson/archive/2005/07/27/1877.aspx)

And there's a follow-up article that compares the two approaches in terms of performance that was published in a back issue of SQL Server Standard. Unfortunately there's no list of back issues on their website so I don't know which issue it was in.

-Jamie

Friday, February 10, 2012

Bunch Of 5 Rows

Hi All,
I have a case in which i have to get the bunch of 5 rows at a time
from database, It could be taken in stored procedure also.
i would like to tell you how should i get results. I
have total 40 rows in my table, if i execute Stored procedure first time, i
should get first 5 rows, second time i should get second 5 rows so and so
for. This way i have to execute this stored procedure 8 times sothat i could
get all 40 rows.
If anybody have solution, plz
help mehttp://www.aspfaq.com/show.asp?id=2120
David Portas
SQL Server MVP
--|||Hi David
I got to know that this is asp code, i want it to all this work
in SQL server only, can @.@.cursor_rows help me?
"David Portas" wrote:

> http://www.aspfaq.com/show.asp?id=2120
> --
> David Portas
> SQL Server MVP
> --
>|||Why would you use a cursor? The ASPFAQ article proposes several
solutions - none of them requires a server-side cursor.
David Portas
SQL Server MVP
--|||On Thu, 11 Aug 2005 22:01:02 -0700, Manish wrote:
>Hi David
> I got to know that this is asp code, i want it to all this work
>in SQL server only, can @.@.cursor_rows help me?
>"David Portas" wrote:
>
Hi Manish,
Visit that URL again. The first few solutions are ASP, but further down
are some SQL Server ways.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)