Re: libpq, ecpg and the bytea data type - Mailing list pgsql-interfaces

From Mark Richardson
Subject Re: libpq, ecpg and the bytea data type
Date
Msg-id 20050915191806.66041.qmail@iso-8859-1-206-190-38-164.yahoo.com
Whole thread Raw
In response to libpq, ecpg and the bytea data type  (Mark Richardson <markmapo@yahoo.com>)
List 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

pgsql-interfaces by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: Beta of DBD::Pg 1.44 available
Next
From: Scott Cain
Date:
Subject: finding indexed functions from pg_index