Re: [SQL] Trigger/Function - one solution - was constraint question (I think)

2008-12-04 Thread Rafael Domiciano
I would develop like this (No so many changes, it is basically a small trigger) create or replace function compound_rows_range_check() returns trigger as $body$ DECLARE BAYNO int4; BEGIN -- First Verification = if changing compound or row fail IF (old.co_id <> new.co_id or old.cr_id <>

[SQL] Aggregates with NaN values

2008-12-04 Thread Sean Davis
I am happy to see NaN and infinity handled in input. I would now like to compute aggregates (avg, min, max, etc) on columns with NaN values in them. The standard behavior (it appears) is to have the aggregate return NaN if the data contain one-or-more NaN values. I am used to using coalesce with

Re: [SQL] Trigger/Function - one solution - was constraint question (I think)

2008-12-04 Thread Gary Stainburn
I have managed to develop one solution using functions and triggers. Has anyone got a better solution? Gary create unique index "compound_bays_unique_index" on compound_bays using btree (co_id,cr_id,cb_id); create or replace function compound_rows_range_check() returns trigger as $proc$ DECLA

[SQL] array index access outside range

2008-12-04 Thread Achilleas Mantzios
Hello list, Let's suppose that we have an inteher array "parents" select parents from machdefs where defid=888; {1,2,3} Currently accessing parents[0] returns a null, which is reasonable, and i am thinking of relying on this assumption. The question is, will it be safe to do that? Is there any tho

[SQL] constraint question (I think)

2008-12-04 Thread Gary Stainburn
Hi folks. I'm trying to model a vehicle compound structure and have the following: Four seperate compounds, North, East, South and West, Each compound has a number of rows with Labels fastened to the fences As the compounds are not perfect rectangles, the rows are of differing lengths. I have