Home > Archive > PostgreSQL Discussion > August 2005 > PQexecParams-Problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author PQexecParams-Problem
Mavinakuli, Prasanna

2005-08-31, 11:23 am

Hi,

Problem Description:

We need to insert binary data to tables and retrieve the
Same-(data type is bytea).
We are using PQExecParams for inserting and retrieving
Data.
Table contains other than binary data also.

When we tried to fetch the integer data (type-int2)
We are not able to get anything from that result set(alws value is
zero).but Pqexec returns the desired value

Questions:

1)how can we get the integer value from the result set which is got from
executing PQexecParams;
(the sample code is given below)

2)if it's not possible then how can we get the BINARY values using
Pqexec

Here is the code snapshot:

string query="select intval from dummy where intval=7;";


res1=PQexecParams(co
nn,query. c_str(),0,NULL,NULL,
NULL,NULL,1);
for(unsigned char i=0;i<4;i++)
{
printf("%d \n" ,(PQgetvalue(res1,0,
0)[i]));
//prints 0000 here
}

cout<<"value from pqexec params
****"<< atoi(PQgetvalue(res1
,0,0))<<endl; //prints 0 here

cout<<"using pqexec ***"<<endl;
res1=PQexec(conn,"select intval from dummy where
intval=7;");//prints 7 below.
cout<<"value from pqexec
**"<< atoi(PQgetvalue(res1
,0,0))<<endl;


Prasanna.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Tom Lane

2005-08-31, 1:24 pm

"Mavinakuli, Prasanna (STSD)" <prasanna.b-m@hp.com> writes:
> Here is the code snapshot:
> string query="select intval from dummy where intval=7;";


> res1=PQexecParams(co
nn,query. c_str(),0,NULL,NULL,
NULL,NULL,1);
> for(unsigned char i=0;i<4;i++)
> {
> printf("%d \n" ,(PQgetvalue(res1,0,
0)[i]));
> //prints 0000 here
> }


Um, what's the actual data type of intval? The above would be expected
if it were, say, bigint.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com