Re: Turning column into row

Поиск
Список
Период
Сортировка
От Tille, Andreas
Тема Re: Turning column into row
Дата
Msg-id Pine.LNX.4.44.0205221629000.8932-100000@wr-linux02.rki.ivbb.bund.de
обсуждение исходный текст
Ответ на Re: Turning column into row  ("Wm. G. Urquhart" <wgu@wurquhart.co.uk>)
Ответы Re: Turning column into row
Список pgsql-sql
On Wed, 22 May 2002, Wm. G. Urquhart wrote:

> Not at all if you have for example 6 properties:
>
> Prop 1 = 1 ;
> Prop 2 = 2 ;
> Prop 3 = 4 ;
> Prop 4 = 8 ;
> Prop 5 = 16 ;
> Prop 6 = 32 ;
You are right, I have exactly 6 properties ;-) and actually for this
kind of application it is perfectly all right to proceed this way.
I do not put all of them not in separate columns but into one
column with the concatenated string   Prop 1/Prop 3/Prop 6/
(and strip the remaining '/' afterwards).
While this solution is kind of a hack it fits my needs so far.

> The user will select the properties applicable to the Item; so for this
> example the new item has Properties 1, 3 and 6. These property values are
> added to give a total of 37. This is the value stored in the table column.
>
> Once you have the rows you can then && the Properties column to see if a
> property is set. I know this works as I've done it before in Oracle,
> Oracle even supports bitwise predicates. But I'm not sure if PostgreSQL
> does.
>
> if (Item.Column && Prop1)
>     Do this ;
> else
>    Property Not supported... ;
> end if ;
I see no reason why this should not work - but I even see no real
advantage to store a bitfield instead of just the concatenated string
in a temporary table which is removed afterwards anyway.

Thanks for the further hint
            Andreas.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Christoph Haller
Дата:
Сообщение: Re: Bug with ORDER BY expression [ ASC | DESC ] ?
Следующее
От: "Joel Burton"
Дата:
Сообщение: Re: Turning column into row