pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: Simon Temple <simon.temple@amalto.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: ParameterMetaData getPrecision() always zero?
Date: Fri, 29 Jan 2010 16:35:50 -0500 (EST)
Message-ID: <alpine.BSO.2.00.1001291617290.31378@leary.csoft.net> (raw)
In-Reply-To: <3CF1F297-BA57-4725-830E-DD282228A284@amalto.com>
References: <3CF1F297-BA57-4725-830E-DD282228A284@amalto.com>



On Thu, 28 Jan 2010, Simon Temple wrote:

>     ParameterMetaData m = stat.getParameterMetaData(  );
>     int colWidth = m.getPrecision( parameterIndex );
> 
> For varchar columns I would expect to get the maximum column width.  So 8
> for a varchar(8).
> 
> I always get zero as a result.
>

This is the best the JDBC driver can do.  When preparing a statement, the 
server only returns the datatypes, not additional details about the size. 
This is because the parameters do not always match up with a table column. 
Consider "WHERE replace(col, 'a', 'bb') = ?"  you won't be able to tell 
the parameter size from that.

Kris Jurka



view thread (2+ messages)

Message-ID: <alpine.BSO.2.00.1001291617290.31378@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1001291617290.31378@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1001291617290.31378@leary.csoft.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, simon.temple@amalto.com
  Subject: Re: ParameterMetaData getPrecision() always zero?
  In-Reply-To: <alpine.BSO.2.00.1001291617290.31378@leary.csoft.net>
  References: <3CF1F297-BA57-4725-830E-DD282228A284@amalto.com> <alpine.BSO.2.00.1001291617290.31378@leary.csoft.net>

* 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