hi,
I am relatively new to postgresql. Sorry if this is a rather naive
question.
I am trying to store a fixed sized c++ class into the database and
retreive it. What is the simplest (dirtiest?!) way to do it? I couldnt
find any example on the web or in the pgsql/src directories that I could
get to work.
Here is what i did.
I tried defining a column as char(sizeof class) using...
create table firstTable(id integer,className char(sizeofclass));
Then in my c++ program, I used....
char* someVariable=(char*)(&classInstance)
//character handle to the class
exec sql insert into firstTable(id,className)
values(:temp,:someVariable);
//save "someVariable" 'asis' into the column
Then I tried reading the value back in...
someVariable=(char*)malloc(sizeof(class));
memset(someVariable,0,sizeof(class));
exec sql select id, className
into :id,:someVariable
from firstTable
where id = 5;
//read "someVariable" back in
While I got the value of id (and there is definitely a valid record), the
"someVariable" memory location is blank. What am I doing wrong?
In addition to examples available with the distribution, pointers to some
more sample code would help.
Thanks,
Swami.