473,320 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help: ecpg bytea and PQescapeBytea()/PQunescapeBytea()

I'm currently trying to insert binary data into postgres using the
ecpg interface and standard embedded sql.

I have a table defined as...

CREATE TABLE bintest
(
fsize numeric,
bindata bytea
);

I'm reading a binary file using fread() and storing the read results
into an unsigned char buffer.

From reading the newsgroups I guess I'm suppose to escape certain
bytes so the data can be parsed and inserted. I'm currently using
PQescapeBytea() with little success. After escaping the data the
insert fails with bad string or something like that. Do I have to
do anything else before calling the EXEC SQL?

I'm not even sure if the PQescapeBytea() and PQunescapeBytea() can be
used with embedded SQL. I did try putting single quotes around the
result of PQescapeBytea() and that seemed to work for inserting.
When I selected the data back out of the database and used
PQunescapeBytea() the binary data was messed up.

I don't need LO support and bytea seemed the easiest way to go.
Incidently I'm using postgresql 7.3 on Redhat 9.

Any comments, suggestions and help is greatly appreciated.

Cheers!
Nov 12 '05 #1
0 1643

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alvar Freude | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I want to change a column from text to bytea; since it seems that alter table can't change the column type, i have to add a temporary column...
0
by: Alvar Freude | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, the following I posted already on pgsql-bugs -- perhaps someone has a good workaround or fix or can say me that I'm wrong? There seems to...
3
by: Lynn.Tilby | last post by:
I am running 7.1.3... The docs for ecpg in 7.1.3 don't have the -e option in them! YET, ecpg -e WORKS!!! for solving the vacuum problem. Just WHAT does the -e option in ecpg do???? Thanks...
1
by: George Gensure | last post by:
I wanted to ask this on here before going any further. I've got functions that return rowsets, which from the psql shell require me to write selects with AS TBL( ... ) to define the return types....
4
by: David Garamond | last post by:
May I request that connectby() supports BYTEA keys too? My keys are GUID (16-byte stored in BYTEA). In this case, branch_delim does not make sense because the keys should be fixed-length anyway,...
4
by: Taber, Mark | last post by:
We're implementing our first PostgreSQL database, and enjoying it very much. However, we have a table that will store binary image files (pie charts, etc.) for later display on a dynamic webpage. ...
1
by: Jerry LeVan | last post by:
Has anyone found some C code that shows how to load/extract data from a bytea column? thanks Jerry ---------------------------(end of broadcast)--------------------------- TIP 7: don't...
1
by: Jerry LeVan | last post by:
Is there any chance that PQunescapeBytea will always have a \000 at the end of the unescaped buffer? unescvalue = PQgetvalue(lastResult, row, fieldNum); value = PQunescapeBytea(unescvalue,...
0
by: Valerie Schneider DSI/DEV | last post by:
Hi, I have a set of libraries and C/C++ programs with embedded access to a PG database. I'm using ecpg. I'm working on a Linux RedHat9 platform. Until now I was in PG 7.4.2 : $ ecpg --version...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.