pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
imlicit varchar truncation
2+ messages / 2 participants
[nested] [flat]

* imlicit varchar truncation
@ 2011-03-21 14:09  Pavel B. Milovantsev <pav@enterprisewizard.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Pavel B. Milovantsev @ 2011-03-21 14:09 UTC (permalink / raw)
  To: pgsql-jdbc

Hello.

	I meet the difficulties with insert/update commands using Postgresql
JDBC driver.

	Due to problems described previously at 
    
> Re: value too long for type character varying(25) (http://archives.postgresql.org/pgsql-novice/2002-11/msg00166.php)

 and 

>Re: ParameterMetaData getPrecision() always zero? (http://archives.postgresql.org/pgsql-jdbc/2010-01/msg00077.php)

I have to perform an additional call to connection.getMetaData().getColumns() 
in order to obtain the size of inserted/updated varchar field, and either 
truncate the value at the client side, or make explicit truncations as shown 
at (http://www.postgresql.org/docs/9.0/static/datatype-character.html)

The question is, are there any "standard" ways to avoid this excessive
call?
    Have to say that a hand-made DB scheme caching is not the option.

Thank you in advance.
	Pavel Milovantsev.

Attachments:

  signature.asc (application/pgp-signature, 197B) download

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

* Re: imlicit varchar truncation
@ 2011-03-21 15:55  Sean Bowman <pico303@gmail.com>
  parent: Pavel B. Milovantsev <pav@enterprisewizard.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Sean Bowman @ 2011-03-21 15:55 UTC (permalink / raw)
  To: Pavel B. Milovantsev <pav@enterprisewizard.com>; pgsql-jdbc

On 3/21/11 8:09 AM, "Pavel B. Milovantsev" <pav@enterprisewizard.com>
wrote:

>I have to perform an additional call to
>connection.getMetaData().getColumns()
>in order to obtain the size of inserted/updated varchar field, and either
>truncate the value at the client side, or make explicit truncations as
>shown
>at (http://www.postgresql.org/docs/9.0/static/datatype-character.html)
>
>The question is, are there any "standard" ways to avoid this excessive
>call?
>    Have to say that a hand-made DB scheme caching is not the option.
>

This is how I've always done it.

Though are you saying you can't load your database schema when the
application starts and cache the lengths of all the varchars?  Is your
schema that dynamic, that it changes while the application is running?
You're on a dangerous path, my friend.

I'm not trying to be condescending, and I have no idea what the goal of
your app is so it may be appropriate, but 99.9% of the time you shouldn't
be creating new database tables or columns in your application on the fly.
 If this is the case, you might want to sit down with a database expert
and examine your strategies.  There may be a better way to model what
you're trying to accomplish and still get the performance for which you're
looking.





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


end of thread, other threads:[~2011-03-21 15:55 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-03-21 14:09 imlicit varchar truncation Pavel B. Milovantsev <pav@enterprisewizard.com>
2011-03-21 15:55 ` Sean Bowman <pico303@gmail.com>

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