2

I have a binary that look like this

CRN=$\x00\x00\x00\x06\x03 \x00\x00\x00\x01

I want it to be saved in DB like this

update table set column='CRN=$\x00\x00\x00\x06\x03 \x00\x00\x00\x01';

But apparently I think the above is not correct what should I do to insert the following in DB.

1 Answer 1

1

According to the Postgresql docs, you will need to use one of two possible escape sequences.

Both start with E'\. If you use the hex option, you append \x followed by your data in hex representation. Or you could use the ASCII-friendly format where you only have to escape the octets for the non-printable characters by outputting the octal values, e.g. \000. This is assuming you have a bytea column to store the binary data.

Your data seems to be a mixture of raw binary data and printable characters like CRN=$ so it's really up to you.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.