Re: Operation on bit strings with different length

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Operation on bit strings with different length
Дата
Msg-id Pine.LNX.4.30.0112181721220.637-100000@peter.localdomain
обсуждение исходный текст
Ответ на Operation on bit strings with different length  (S P Arif Sahari Wibowo <arifsaha@yahoo.com>)
Список pgsql-sql
S P Arif Sahari Wibowo writes:

> Do you know how to operate (AND, OR, etc.) on bit strings with
> dynamically different length? It is dynamic, means the length won't be
> determined until run time.
> Is there any function to extend the length of a bit string to a certain
> length?

Something along the lines of

SUBSTRING ( your_value || B'000000000000...long enough...000' FROM 1 FOR max_length )

The reason this is not done automatically is that it's not clear whether
the extension should be to the left or to the right.  Either of these
could be appropriate, depending on whether you consider bit strings to be
strings or numbers.  Once you know what you want in your application you
can wrap the above into a function.  To generate a generic "long enough"
value, look at the REPEAT function.

-- 
Peter Eisentraut   peter_e@gmx.net



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

Предыдущее
От: Iklódi Lajos
Дата:
Сообщение: Re: Execution time problem
Следующее
От: Gurudutt
Дата:
Сообщение: Maximum Execution Timeout Error!!