Not able to insert binary Data having NULL

Started by Manish Jainover 18 years ago3 messagesgeneral
Jump to latest
#1Manish Jain
manish.jain@globallogic.com

Hi,

I have bytea column in one table and using C language, I am trying to
insert a binary data (having NULLs)

into bytea column, but it just inserts/updates till NULL reached.

Please let know whether I am missing something.

Any other approach - may I use some data type instead of bytea so that
any binary data can go there?

Best Regards,

Manish Jain

#2Richard Huxton
dev@archonet.com
In reply to: Manish Jain (#1)
Re: Not able to insert binary Data having NULL

Manish Jain wrote:

I have bytea column in one table and using C language, I am trying to
insert a binary data (having NULLs)

into bytea column, but it just inserts/updates till NULL reached.

Please let know whether I am missing something.

Probably, but you'll need to explain how you're doing it at the moment.

How are you escaping your binary data?

--
Richard Huxton
Archonet Ltd

#3Laurenz Albe
laurenz.albe@cybertec.at
In reply to: Manish Jain (#1)
Re: Not able to insert binary Data having NULL

Manish Jain wrote:

I have bytea column in one table and using C language, I am
trying to insert a binary data (having NULLs)

into bytea column, but it just inserts/updates till NULL reached.

Please let know whether I am missing something.

I guess that when you say NULL you don't mean SQL NULL, but
the byte E'\\000', right? The rest of my E-Mail is based on
that assumption.

When calling PQexecParams to store a bytea, either set
paramFormats[i] to 0 (text) and use escape sequences as above,
or set paramFormats[i] to 1 (binary) and dont't forget to set
paramLengths[i] to the length of the binary data.

Any other approach - may I use some data type instead of
bytea so that any binary data can go there?

Large Objects.
But there's nothing wrong with bytea.

Yours,
Laurenz Albe