From: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> |
---|---|
To: | Jorge Maturana Ortiz <ateo(at)labsd(dot)inf(dot)utfsm(dot)cl>, pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] correlative insertion |
Date: | 1998-10-14 09:49:23 |
Message-ID: | l03110701b24a238badbe@[194.90.105.28] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Good | 1998-10-14 13:06:01 | Using the IN predicate in an UPDATE... |
Previous Message | Herouth Maoz | 1998-10-14 09:46:13 | Re: [SQL] dilemma |