Export Text field to Bytea in Postgresql

Asked

Viewed 310 times

1

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

If that is possible clear.

I have a table with a Text field like Text, the contents of this field is a complex text, I need to transform this text and RTF (Richedit) and then save it in the Bytea type Helper field, which receives binary files.

You can update a Text field to a Bytea?

Example:

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

I tried with CAST, but he can’t turn the text content into binary

  • https://www.postgresql.org/message-id/475FEAE6.7090902%40archonet.com

1 answer

1


Use the function convert_to that returns bytea:

update tabela1 
set campobytea = convert_to(campotexto, 'UTF8')
where (codigo = 1234)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.