Re: Fields

Lists: pgsql-jdbc
From: "Guy Rouillier" <guyr(at)masergy(dot)com>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Fields
Date: 2006-05-31 20:51:39
Message-ID: D4D1632DC736E74AB95FE78CD60900790126AC@mtxexch01.add0.masergy.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Charles Curi wrote:
> Hi people!!!
> I have a table called "orders" with fields "a","b" and "c".
> I want to make a INSERT only of fields "a" and "b" by Java and at
> this moment c=a*b; Is it possible?

I think you are saying you want your Java code to insert fields "a" and
"b" and have "c" automatically set to a value derived from "a" and "b".
If so, you can accomplish this with an insert trigger.

--
Guy Rouillier


From: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
To: Guy Rouillier <guyr(at)masergy(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Fields
Date: 2006-05-31 20:56:13
Message-ID: 1149108973.20798.3.camel@archimedes
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Wed, 2006-05-31 at 15:51 -0500, Guy Rouillier wrote:
> Charles Curi wrote:
> > Hi people!!!
> > I have a table called "orders" with fields "a","b" and "c".
> > I want to make a INSERT only of fields "a" and "b" by Java and at
> > this moment c=a*b; Is it possible?
>
> I think you are saying you want your Java code to insert fields "a" and
> "b" and have "c" automatically set to a value derived from "a" and "b".
> If so, you can accomplish this with an insert trigger.
>

Or you could just insert a, b and a*b yourself . . . . or am I missing
something here?

-- Mark


From: "EBIHARA, Yuichiro" <ebihara(at)iplocks(dot)co(dot)jp>
To: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Fields
Date: 2006-06-01 01:14:22
Message-ID: 001901c68518$b7cd6b40$360aa8c0@ipljp.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hi,

Another solution may be a view as follows.

create table orders (a int, b int);
create view orders_v as select a, b, a * b as c from orders;

ebi

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Mark Lewis
> Sent: Thursday, June 01, 2006 5:56 AM
> To: Guy Rouillier
> Cc: pgsql-jdbc(at)postgresql(dot)org
> Subject: Re: [JDBC] Fields
>
>
> On Wed, 2006-05-31 at 15:51 -0500, Guy Rouillier wrote:
> > Charles Curi wrote:
> > > Hi people!!!
> > > I have a table called "orders" with fields "a","b" and
> "c". I want
> > > to make a INSERT only of fields "a" and "b" by Java and at this
> > > moment c=a*b; Is it possible?
> >
> > I think you are saying you want your Java code to insert fields "a"
> > and "b" and have "c" automatically set to a value derived
> from "a" and
> > "b". If so, you can accomplish this with an insert trigger.
> >
>
> Or you could just insert a, b and a*b yourself . . . . or am
> I missing something here?
>
> -- Mark
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>
>