pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brijesh Shrivastav <Bshrivastav@esri.com>
To: 'L J Bayuk' <ljb220@mindspring.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Is there a way to describe precision and scale f
Date: Mon, 7 Jun 2004 17:52:11 -0700
Message-ID: <491DC5F3D279CD4EB4B157DDD62237F401ADE475@zipwire.esri.com> (raw)

Thanks for the comments. They were very helpful.  

However, I am still not sure about the second problem 
i.e. of describing the prepared  statement. Does some 
other api exposes it? Can I use some sql command to get 
around it (I couldn't find any)? any other ideas?

Brijesh Shrivastav

-----Original Message-----
From: L J Bayuk [mailto:ljb220@mindspring.com]
Sent: Sunday, June 06, 2004 5:44 PM
To: Bshrivastav@esri.com
Cc: pgsql-interfaces@postgresql.org
Subject: Re: [INTERFACES] Is there a way to describe precision and scale
for columns in a s


Brijesh Shrivastav wrote:
> 
> Hi! All,
> 
> I am a new postgres developer and as is the case with many of us I am
> porting
> an existing application to postgres database. One of the requirement for
us
> is to be able to determine the scale and precision for select columns so
we
> can
> accordingly allordingly allocate memory or inform client applications. 
> 
> I looked at libpq api and found following api to describe a select
statement
> 
> PQfname()
> PQftype()
> PQfsize()
> 
> However, PQfsize() gives me the space alloced for this column in database
> row. How
> can I get precision and scale for numeric columns?

It's a little tricky. Use PQfmod() on the column.  Call the result F.
The precision is the high 16 bits, and the scale is the low 16 bits,
but with an offset of 4 first:
     precision = ((F - 4)  >> 16) & 0xffff;
     scale = (F - 4) & 0xffff;

> I have run into another problem. I execute PREPARE statement with pgexec
to
> prepare 
> the query before executing it multiple time with different parameter
values.
> It 
> seems I can't get the select column information untill I perform an
> PQexecPrepared().
> Is there any way around it?

I don't think so. The protocol supports it ("Describe" message on a named
prepared statement, without Bind or Execute), and I assume the backend
would play along, but I don't think libpq has any way to let you do it
in the current release.



view thread (5+ messages)  latest in thread

Message-ID: <491DC5F3D279CD4EB4B157DDD62237F401ADE475@zipwire.esri.com>
Permalink:  ../491DC5F3D279CD4EB4B157DDD62237F401ADE475@zipwire.esri.com/
Also on:    postgresql.org/message-id/491DC5F3D279CD4EB4B157DDD62237F401ADE475@zipwire.esri.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: Bshrivastav@esri.com, ljb220@mindspring.com
  Subject: Re: Is there a way to describe precision and scale f
  In-Reply-To: <491DC5F3D279CD4EB4B157DDD62237F401ADE475@zipwire.esri.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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