Subject RE: [ib-support] creating tables
Author Wilson, Fred
The ideal thing would be to describe (perhaps not in MS SQLServer SQL),
what you need to do (real case), as in a specific example with DDL (table,
etc) descriptions, and maybe someone will show you the IB/FB way ;)


Best regards,
Fred Wilson
SE, Bell & Howell
fred.wilson@...


-----Original Message-----
From: PODESTA Mariano APRE [mailto:SIDTMPO@...]
Sent: Tuesday, June 25, 2002 2:07 PM
To: ib-support@yahoogroups.com
Subject: RE: [ib-support] creating tables


hello,
dynamic pivot is where you don't know the number of columns before hand.
this is an example on m$ sql 2000 (not a real case):


Create Table #tmp(
IdKey char(10)
)

insert into #tmp (IdKey)
select distinct KeyColumn
from SourceTable

declare @IdKey char(10), @Value varchar(10)
declare @Values CURSOR

EXEC EnumFilterOptions @Values output

FETCH NEXT FROM @Values INTO @Value
WHILE (@@FETCH_STATUS = 0)
BEGIN
Exec doAddColumn @Value
FETCH NEXT FROM @Values INTO @Value
END
CLOSE @Values
DEALLOCATE @Values


procedure doAddColumn @Value
AS
execute 'ALTER TABLE #tmp ADD '+@Value+' int null'
execute 'update #tmp
set '+@Value+' = Val
from SourceTable inner join #tmp
on IdKey = KeyColumn
where SourceTable.FilterColumn = '+@Value


PROCEDURE EnumFilterOptions(@Values CURSOR VARYING OUTPUT)
AS
SET @Values = CURSOR
FORWARD_ONLY STATIC FOR
select distinct FilterColumn
from SourceTable
OPEN @Values


> -----Original Message-----
> From: PUB: Doug Chamberlin [mailto:DChamberlin@...]
> Sent: Martes, 25 de Junio de 2002 17:30
> To: ib-support@yahoogroups.com
> Subject: RE: [ib-support] creating tables
>
>
> At 06/25/2002 03:39 PM (Tuesday), PODESTA Mariano
> APRE wrote:
> >there are many cases where the best solution are temporary tables.
> >one could be: making a dynamic pivot?
>
> I would re-phrase this to be "There are some cases where a
> viable solution
> is temporary tables." However, there are far more cases where
> the need for
> temporary tables is eliminated if you approach the problem in
> a different
> way. See below.
>
> >please do not answer with another question.
>
> The reason he did that was because long-time members of the
> Firebird/Interbase community are very used to hearing the request for
> temporary tables. Since they are a common solution when using
> other RDBMS
> products, newcomers to FB/IB can often be found to be
> searching for these
> old friends.
>
> The fact is they are not to be found in the same form you are
> used to.
> However, the good news is that we are really, really good at finding
> alternatives. So, if you provide enough details of what you
> are trying to
> accomplish we may very well be able to find a solution. Thus
> the questions.
>
> My question is: What's a "dynamic" pivot as opposed to a
> regular pivot? ;)
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Free $5 Love Reading
> Risk Free!
> http://us.click.yahoo.com/3PCXaC/PfREAA/Ey.GAA/67folB/TM
> --------------------------------------------------------------
> -------~->
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
>
>


To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/