pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Jorge Maturana Ortiz <ateo@labsd.inf.utfsm.cl>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] correlative insertion
Date: Wed, 14 Oct 1998 11:49:23 +0200
Message-ID: <l03110701b24a238badbe@[194.90.105.28]> (raw)
In-Reply-To: <3623D1B6.A3ECF2AA@labsd.inf.utfsm.cl>

At 0:18 +0200 on 14/10/98, Jorge Maturana Ortiz wrote:


>
> create function otro(char) returns int4 as 'select 1 + max(num) from
> mas where cha = $1;' language 'sql';
>
> it works OK if i make the following:
>
> insert into mas values ('a',otro('a'));
>
> i obtain:
>
>   cha|num
> ---+---
>     a  |  1
>     a  |  2
>     a  |  3
>  
>
> THE PROBLEM is that when i try to insert a tuple with an unknow cha,
> this function don't work.

Doesn't work *how*? What does it do? In a cursory look, it seems as if the
function just returns NULL when the character is not known. If so, why
don't you define the num field in the table as NOT NULL DEFAULT 1? In that
case, inserting a NULL should invoke the default.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (2+ messages)

Message-ID: <l03110701b24a238badbe@[194.90.105.28]>
Permalink:  ../l03110701b24a238badbe@%5B194.90.105.28%5D/
Also on:    postgresql.org/message-id/l03110701b24a238badbe@[194.90.105.28]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, ateo@labsd.inf.utfsm.cl
  Subject: Re: [SQL] correlative insertion
  In-Reply-To: <l03110701b24a238badbe@[194.90.105.28]>
  References: <3623D1B6.A3ECF2AA@labsd.inf.utfsm.cl> <l03110701b24a238badbe@[194.90.105.28]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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