Обсуждение: Fields

Поиск
Список
Период
Сортировка

Fields

От
"Charles Curi"
Дата:
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?

Re: Fields

От
"Guy Rouillier"
Дата:
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

Re: Fields

От
Mark Lewis
Дата:
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

Re: Fields

От
"EBIHARA, Yuichiro"
Дата:
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@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Mark Lewis
> Sent: Thursday, June 01, 2006 5:56 AM
> To: Guy Rouillier
> Cc: pgsql-jdbc@postgresql.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
>
>
>