pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Bug extracting money value
5+ messages / 4 participants
[nested] [flat]

* Bug extracting money value
@ 2006-09-30 23:09  Holger Schulz <hst1@online.de>
  0 siblings, 1 reply; 5+ messages in thread

From: Holger Schulz @ 2006-09-30 23:09 UTC (permalink / raw)
  To: pgsql-jdbc

Hello!


I always get an exception when I try to extract the money value I inserted this way:

insert into public."dbtypes" ("cmoney") values ('7').

Java:
Object oValue = m_resultSet.getObject(i);

Stacktrace (postgresql-8.2dev-503.jdbc3.jar):
org.postgresql.util.PSQLException: Bad value for type double : ?7,00
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.toDouble(AbstractJdbc2ResultSet.java:2594)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getDouble(AbstractJdbc2ResultSet.java:1975)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.internalGetObject(AbstractJdbc2ResultSet.java:132)
	at org.postgresql.jdbc3.AbstractJdbc3ResultSet.internalGetObject(AbstractJdbc3ResultSet.java:39)
	at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getObject(AbstractJdbc2ResultSet.java:2291)

resultSet.getDouble(i);  doesn't work either.
resultSet.getString(i); returns '?7,00' without exception.

Tested with:
PostgreSQL 8.1.4 on Windows 2000
JDBC driver: postgresql-8.2dev-503.jdbc3.jar AND postgresql-8.1-407.jdbc3.jar

Thanks

     Holger




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

* Re: Bug extracting money value
@ 2006-10-01 21:11  Oliver Jowett <oliver@opencloud.com>
  parent: Holger Schulz <hst1@online.de>
  0 siblings, 2 replies; 5+ messages in thread

From: Oliver Jowett @ 2006-10-01 21:11 UTC (permalink / raw)
  To: Holger Schulz <hst1@online.de>; +Cc: pgsql-jdbc

Holger Schulz wrote:

> I always get an exception when I try to extract the money value I inserted this way:

"money" isn't a well-supported type on the server side (I believe its 
use is no longer recommended) .. IIRC the formatting rules for it are 
locale-specific, among other problems.

> Object oValue = m_resultSet.getObject(i);

> org.postgresql.util.PSQLException: Bad value for type double : ?7,00

... though I'd expect at least getObject to work, if not getDouble()

Maybe you could dig into this and send us a patch?

-O



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

* Re: Bug extracting money value
@ 2006-10-02 07:03  Markus Schaber <schabi@logix-tt.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Markus Schaber @ 2006-10-02 07:03 UTC (permalink / raw)
  To: pgsql-jdbc; +Cc: Holger Schulz <hst1@online.de>

Hi, Oliver,

Oliver Jowett wrote:

>> I always get an exception when I try to extract the money value I
>> inserted this way:
> 
> "money" isn't a well-supported type on the server side (I believe its
> use is no longer recommended) .. IIRC the formatting rules for it are
> locale-specific, among other problems.

Without having looked at the code, I think that the ? in getString()
comes from the backend formatting the Value with an EUR symbol, and the
JDBC driver looking for a $ to skip.

HTH,
Markus

-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org



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

* Re: Bug extracting money value
@ 2006-10-02 07:36  Markus Schaber <schabi@logix-tt.com>
  parent: Markus Schaber <schabi@logix-tt.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Markus Schaber @ 2006-10-02 07:36 UTC (permalink / raw)
  To: pgsql-jdbc

Hi, All,

Markus Schaber wrote:

> Without having looked at the code, I think that the ? in getString()
> comes from the backend formatting the Value with an EUR symbol, and the
> JDBC driver looking for a $ to skip.

I now looked at the code.

It seems that the Code tries to strip brackets () and anything outside
of them, however, I did not get my backend to generate anything
containing brackets.

With the US locale, it generated '$5.00' and '-$5.00', with the european
locale, it generated '5.00' and '-5.00'.

HTH
Markus


-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org



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

* Re: Bug extracting money value
@ 2006-10-02 11:15  Dave Cramer <pg@fastcrypt.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  1 sibling, 0 replies; 5+ messages in thread

From: Dave Cramer @ 2006-10-02 11:15 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: Holger Schulz <hst1@online.de>; pgsql-jdbc


On 1-Oct-06, at 5:11 PM, Oliver Jowett wrote:

> Holger Schulz wrote:
>
>> I always get an exception when I try to extract the money value I  
>> inserted this way:
>
> "money" isn't a well-supported type on the server side (I believe  
> its use is no longer recommended)
This is still being debated, and will likely be reversed as there is  
a proposal on the table for a new improved money type

> .. IIRC the formatting rules for it are locale-specific, among  
> other problems.
>
>> Object oValue = m_resultSet.getObject(i);
>
>> org.postgresql.util.PSQLException: Bad value for type double : ?7,00
>
> ... though I'd expect at least getObject to work, if not getDouble()
>
> Maybe you could dig into this and send us a patch?
>
> -O
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>




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


end of thread, other threads:[~2006-10-02 11:15 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-30 23:09 Bug extracting money value Holger Schulz <hst1@online.de>
2006-10-01 21:11 ` Oliver Jowett <oliver@opencloud.com>
2006-10-02 07:03   ` Markus Schaber <schabi@logix-tt.com>
2006-10-02 07:36     ` Markus Schaber <schabi@logix-tt.com>
2006-10-02 11:15   ` Dave Cramer <pg@fastcrypt.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