Hi matt,This is my take. I guess this is also your solution ( encode(fteld, 'hex'): :macaddr )SELECT encode(fteld, 'hex'): :macaddr FROM ((VALUES (decode('aabbccddeeff', 'hex'))))AS x(field)--BorisAm 28.09.2023 um 17:01 schrieb Matt Zagrabelny <mzagrabe@d.umn.edu>:Greetings Pg folks,I have a database schema (not mine) that uses bytea to represent a MAC address. I'd like to create a view that casts that field into a MACADDR type.# \d lease4 Table "public.lease4" Column │ Type │ Collation │ Nullable │ Default ════════════════╪══════════════════════════╪═══════════╪══════════╪═════════ hwaddr │ bytea │ │ │ # select hwaddr from lease4; hwaddr ════════════════ \x9cebe803e3b9It looks like I can cast the bytea to text and then manipulate that and finally cast it to macaddr.Is there a better, or more canonical, way to convert/cast this field?Thanks for any help!-m
SELECT encode(fteld, 'hex'): :macaddr FROM ((VALUES (decode('aabbccddeeff', 'hex'))))
AS x(field)
Am 28.09.2023 um 17:01 schrieb Matt Zagrabelny <mzagrabe@d.umn.edu>:
Greetings Pg folks,I have a database schema (not mine) that uses bytea to represent a MAC address. I'd like to create a view that casts that field into a MACADDR type.# \d lease4 Table "public.lease4" Column │ Type │ Collation │ Nullable │ Default ════════════════╪══════════════════════════╪═══════════╪══════════╪═════════ hwaddr │ bytea │ │ │ # select hwaddr from lease4; hwaddr ════════════════ \x9cebe803e3b9It looks like I can cast the bytea to text and then manipulate that and finally cast it to macaddr.Is there a better, or more canonical, way to convert/cast this field?Thanks for any help!-m
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных