pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to get OID return value(pls help me)
3+ messages / 2 participants
[nested] [flat]

* How to get OID return value(pls help me)
@ 2005-12-22 05:35 sandhya <sandhyar@amiindia.co.in>
  2005-12-22 06:31 ` Re: How to get OID return value(pls help me) Michael Fuhr <mike@fuhr.org>
  0 siblings, 1 reply; 3+ messages in thread

From: sandhya @ 2005-12-22 05:35 UTC (permalink / raw)
  To: pgsql-admin; +Cc: sandhya <sandhyar@amiindia.co.in>

Hi......


My table consists of oid and varchar datatypes.
I want to get the oid type from the table and i need to pass it to a function which accepts only the oid data type.
But my problem is the return value of the datatype i am getting from the query result is char*.
Is there any function in postgresql which gives the return value of the executed query as OID type.

Please explain me what to do inorder to get the Oid type 
When i used PQoidValue(res).It is giving 0.
Also in document they mention something related to INSERT query only.
But i want it for select query.
Thank you,
Regards,
Sandhya

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to get OID return value(pls help me)
  2005-12-22 05:35 How to get OID return value(pls help me) sandhya <sandhyar@amiindia.co.in>
@ 2005-12-22 06:31 ` Michael Fuhr <mike@fuhr.org>
  0 siblings, 0 replies; 3+ messages in thread

From: Michael Fuhr @ 2005-12-22 06:31 UTC (permalink / raw)
  To: sandhya <sandhyar@amiindia.co.in>; +Cc: pgsql-admin

On Thu, Dec 22, 2005 at 11:05:22AM +0530, sandhya wrote:
> My table consists of oid and varchar datatypes.
> I want to get the oid type from the table and i need to pass it to
> a function which accepts only the oid data type.

What function is that?  What does it do with the oid?

> But my problem is the return value of the datatype i am getting from
> the query result is char*.

You don't mention what language and interface you're using but it
sounds like C and libpq.

> Is there any function in postgresql which gives the return value of
> the executed query as OID type.

You could rely on the knowledge that Oid is

typedef unsigned int Oid;

and use strtoul() to convert the char * to an unsigned int.  Another
way, if you're using 7.4 or later, would be to issue the query with
PQexecParams() and request binary results.  I think you'll have to
deal with byte order issues in that case.

This is off-topic for pgsql-admin; pgsql-interfaces or pgsql-general
would be more appropriate.

-- 
Michael Fuhr



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Fw: How to get OID return value(pls help me)
@ 2005-12-22 07:46 sandhya <sandhyar@amiindia.co.in>
  0 siblings, 0 replies; 3+ messages in thread

From: sandhya @ 2005-12-22 07:46 UTC (permalink / raw)
  To: Michael Fuhr <mike@fuhr.org>; +Cc: pgsql-admin; sandhya <sandhyar@amiindia.co.in>


----- Original Message ----- 
From: "sandhya" <sandhyar@amiindia.co.in>
To: "Michael Fuhr" <mike@fuhr.org>
Sent: Thursday, December 22, 2005 1:15 PM
Subject: Re: [ADMIN] How to get OID return value(pls help me)


> What function is that?  What does it do with the oid?
>
> It is normal C function ...with that oid it tries to open the object which
i
> stored in database.
>
> You don't mention what language and interface you're using but it
>  sounds like C and libpq.
> Yes...it's C-libpq only
>
> and use strtoul() to convert the char * to an unsigned
> This solved my problem.
> Thank you very much Michael.
>
> Regards,
> Sandhya
>
>
> ----- Original Message ----- 
> From: "Michael Fuhr" <mike@fuhr.org>
> To: "sandhya" <sandhyar@amiindia.co.in>
> Cc: "postgre" <pgsql-admin@postgresql.org>
> Sent: Thursday, December 22, 2005 12:01 PM
> Subject: Re: [ADMIN] How to get OID return value(pls help me)
>
>
> > On Thu, Dec 22, 2005 at 11:05:22AM +0530, sandhya wrote:
> > > My table consists of oid and varchar datatypes.
> > > I want to get the oid type from the table and i need to pass it to
> > > a function which accepts only the oid data type.
> >
> > What function is that?  What does it do with the oid?
> >
> > > But my problem is the return value of the datatype i am getting from
> > > the query result is char*.
> >
> > You don't mention what language and interface you're using but it
> > sounds like C and libpq.
> >
> > > Is there any function in postgresql which gives the return value of
> > > the executed query as OID type.
> >
> > You could rely on the knowledge that Oid is
> >
> > typedef unsigned int Oid;
> >
> > and use strtoul() to convert the char * to an unsigned int.  Another
> > way, if you're using 7.4 or later, would be to issue the query with
> > PQexecParams() and request binary results.  I think you'll have to
> > deal with byte order issues in that case.
> >
> > This is off-topic for pgsql-admin; pgsql-interfaces or pgsql-general
> > would be more appropriate.
> >
> > -- 
> > Michael Fuhr
> >
>






^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-12-22 07:46 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-12-22 05:35 How to get OID return value(pls help me) sandhya <sandhyar@amiindia.co.in>
2005-12-22 06:31 ` Michael Fuhr <mike@fuhr.org>
2005-12-22 07:46 Fw: How to get OID return value(pls help me) sandhya <sandhyar@amiindia.co.in>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox