Skip site navigation (1) Skip section navigation (2)

Re: Aggregate function: Different results with jdbc and psql

From: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
To: "Tilman Rassy" <rassy(at)math(dot)TU-Berlin(dot)DE>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Aggregate function: Different results with jdbc and psql
Date: 2008-10-07 12:48:42
Message-ID: CA896D7906BF224F8A6D74A1B7E54AB3039E8BFA@JENMAIL01.ad.intershop.net (view raw or flat)
Thread:
Lists: pgsql-jdbc
Hello,

maybe you try to retrieve the value of grade with an inappropriate
method ?

What are the data types returned with psql ?


HTH,

Marc Mamin
 

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Tilman Rassy
Sent: Tuesday, October 07, 2008 1:27 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: [JDBC] Aggregate function: Different results with jdbc and psql

Hello,

I have the following problem: A certain query, i.e.,

SELECT * FROM user_worksheet_grades WHERE user_id = 23 AND worksheet_id
= 105;

gives

 worksheet_id | user_id | num_edited | num_corrected | grade 
--------------+---------+------------+---------------+-------
          105 |      23 |          1 |             1 |     4
(1 row)

when I issue it in psql. When I use the same query from JDBC in Java,
the column "grade" is SQL NULL.

The table "user_worksheet_grades" is actually a view which gets its data
from two other views, one of which is defined as follows:

SELECT
  wks.id AS worksheet_id,
  ann.the_user AS user_id,
  count(ann.ann_type) AS num_corrected,
  sum(ref_wks_prb.points * ann.score) AS grade FROM  latest_worksheets
wks, refs_worksheet_generic_problem ref_wks_prb,
anns_user_worksheet_generic_problem ann WHERE ann.ref = ref_wks_prb.id
AND ref_wks_prb.from_doc = wks.id AND ann.ann_type = 2 GROUP BY wks.id,
ann.the_user;

Thus, "grade" is defined as a sum of products.

I use PostgreSQL 8.2.3 on Linux.

Any help will be appreciated!

Tilman

--
Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

In response to

Responses

pgsql-jdbc by date

Next:From: Tilman RassyDate: 2008-10-07 12:53:32
Subject: Re: Aggregate function: Different results with jdbc and psql
Previous:From: Guillaume CottenceauDate: 2008-10-07 12:42:10
Subject: Re: Aggregate function: Different results with jdbc and psql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group