From: | Mark Richardson <markmapo(at)yahoo(dot)com> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: libpq, ecpg and the bytea data type |
Date: | 2005-09-15 19:18:05 |
Message-ID: | 20050915191806.66041.qmail@unknown-206-190-38-164.yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Thanks Michael, I appreciate your help.
I could have sworn that I tried the COPY from stdin with the double backslash and ended up with the same result. But I tried that and it seems to work.
I also mistyped a couple of things, like the
SELECT length(myByteField) FROM stdin;
which should have been
SELECT length(myByteField) FROM myTable;
You are also correct that I ran the function PQgetlength and not PQgetLength. I tried that after I used the double slash with the COPY function and that worked as expected (my bad on the double slash).
But the ECPG part still doesn't seem to have the correct behavior. With the following in a .pgc file...
EXEC SQL DECLARE SECTION;
char myByteField_[3][8];
int fetchRows=3;
EXEC SQL END DECLARE SECTION;
for (int i=0; i<3; i++)
for (int j=0; j<8; j++)
myByteField[i][j]='*';
EXEC SQL CONNECT ...
EXEC SQL DECLARE myCursor BINARY CURSOR FOR SELECT myByteaField FROM myTable FOR READ ONLY;
EXEC SQL OPEN myCursor;
EXEC SQL FETCH :fetchRows myCursor INTO :myByteField_;
EXEC SQL CLOSE myCursor;
for (int i=0;i<3;i++)
for (int j=0;j<8;j++)
std::cout << myByteaField_[i][j] << "(" << int(myByteaField_[i][j] << ").";
std::cout << std::endl;
Shows the following output...
(0).(0).(0).(0).(0).(0).(0).(0). <- correct
(9).A(65).?(-122).m(109).^(94). (29).9(57).](93). <- correct
(10).(0).(0).(0).(0).(0).(0).(0). <- not correct (stopped at '\0')
So all is as it should be with only the ECPG part eluding me. Thank you again for showing me the error of my ways (I swear I did see the double slash for populating the bytea field, but it didn't seem to make a difference - now I know better).
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2005-09-16 00:22:22 | Re: libpq, ecpg and the bytea data type |
Previous Message | Michael Fuhr | 2005-09-15 09:08:15 | Re: libpq, ecpg and the bytea data type |