Re: [SQL] Database diagram

2004-01-22 Thread Chris Travers
There is a free Perl script which is called something like pgautodoc which
creates DIA diagrams from databases.  Take a look for it on Freshmeat.
- Original Message -
From: "Ganesan Kanavathy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, January 20, 2004 1:38 PM
Subject: [SQL] Database diagram


> I have a postgres database with many tables.
>
> How do I create database diagram? Are there any free tools available to
> create database diagram from pgsql database?
>
> Regards,
> Ganesan
>
>
>
>
> ---(end of broadcast)---
> TIP 8: explain analyze is your friend
>
>


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])


[SQL] Batch update issue

2004-01-22 Thread beyaRecords - The home Urban music
Hi,
my first question is, is pg74jdbc3.2.jar the latest driver for postgresql? If so, does it support batch updates? I ask this because I am using Hibernate, or trying to should I say!, to do EJB stuff to postgresql and when I try to commit() data to a postgresql table i get the following error:

'Could not execute JDBC batch update'


Uzo

Re: [SQL] How can I get the last element out of GROUP BY sets?

2004-01-22 Thread Greg Stark
Tom Lane <[EMAIL PROTECTED]> writes:

> Robert Creager <[EMAIL PROTECTED]> writes:
> > ... one piece of data I need is the last value for each GROUP BY
> > period.  Alas, I cannot figure out how to do this.
> 
> SELECT DISTINCT ON (rather than GROUP BY) could get this done for you.

Or if you need to combine this with other aggregate functions like sum, count,
etc:

CREATE FUNCTION first_accum (integer, integer) RETURNS integer AS 'select 
coalesce($1,$2)' LANGUAGE sql;
CREATE FUNCTION last_accum (integer, integer) RETURNS integer AS 'select $2' LANGUAGE 
sql;
CREATE AGGREGATE first (BASETYPE = integer, SFUNC = first_accum, STYPE = integer);
CREATE AGGREGATE last (BASETYPE = integer, SFUNC = last_accum, STYPE = integer);

Then you can do first() and last(). These definitions only work for integer
but you can pattern match for other datatypes. You might be able to get a
universal function working using anyelement now, I haven't tried.

-- 
greg


---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match