From: | GOO Creations <goocreations(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: libpq (C++) - Insert binary data |
Date: | 2010-09-30 15:36:29 |
Message-ID: | 4CA4AE7D.9000404@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I've worked through that already, without any success.
This is what I have until now to insert data
char *query = "insert into table1 (bytes) values ($1)";
QByteArray chip = <assignment of bytes>;
const char *data = chip->data();
const char* params[]={data};
const int params_length[]={chip->length()};
const int params_format[]={1};
result = PQexecParams(mDatabase, query, 1, in_oid, params,
params_length, params_format, 0);
The first problem I have is that I'm not sure if const int
params_length[]={chip->length()}; is the correct way to provide the
length. Second of all, is this actually the correct way of doing it,
isn't there a beter way?
Christoph
On 2010/09/30 05:30 PM, Vincenzo Romano wrote:
> 2010/9/30 GOO Creations<goocreations(at)gmail(dot)com>:
>> Hi there,
>>
>> I'm sitting for days now, and I can't get this to work:
>>
>> I want to insert binary data (bytea) into my postgres DB via the c++ libpq.
>>
>> What I have is a char* (actually a QByteArray) and I want to insert it into
>> the DB and the retrieve it from there again.
>>
>> I can't find any good examples or tutorials online, so can anyone help me
>> (or direct met to a tutorial) on how to insert binary data and retrieve it
>> again?
>>
>> Thank you very much
>> Christoph
> Try chapter 31.3.4 from the v9 documentation.
> http://www.postgresql.org/docs/9.0/static/libpq-exec.html#LIBPQ-EXEC-ESCAPE-STRING
>
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Atkins | 2010-09-30 15:38:25 | Re: libpq (C++) - Insert binary data |
Previous Message | Vincenzo Romano | 2010-09-30 15:33:03 | Re: libpq (C++) - Insert binary data |