Export Text field to Bytea in PostgreSQL

0

I could make an application to export the contents of a Text field to Bytea without problems, but as they are thousands of records I believe that if I do via SQL it will be faster.

If this is possible of course.

I have a table with a text field Text type, the content of this field is a complex text, I need to transform this text and RTF (RichEdit) and then write it in the Auxiliary field type Bytea, which receives binary files. >

How can I get an UPDATE of a Text field for a Bytea?

Example:

update tabela1 set campobytea = campotexto
where (codigo = 1234)

I've tried with CAST, but it can not turn the text into binary

    
asked by anonymous 27.06.2018 / 17:36

1 answer

1

Use the convert_to function that returns bytea:

update tabela1 
set campobytea = convert_to(campotexto, 'UTF8')
where (codigo = 1234)
    
27.06.2018 / 18:42