I see... The bad news is you can't do it directly... You can only create functions to run as triggers, not plain sql statements for some reason :-(
The problem is I don't know how to convert the following pseudo code to valid SQL:
create trigger unique_current on insert/update to lnumbers if new.lncurrent = true update lnumbers set all other records for this loco to false
The correct syntax is
create trigger unique_current before insert or update on lnumbers for each row execute procedure reset_current_lnum();
Where reset_current_lnum () is a function, that you have to write either in "C" or in 'plpgsql';
I could give you some sample code in "C" to do that, but it's rather complicated if you are not used to writing postgres stored procs in C...
plpgsql would be much easier, but I can't help you there, because I don't know the syntax ... something like this, I guess, but I doubt this will compile exactly as it is:
create function reset_current_lnum () returns triggers as
'
begin
if new.lncurrent = true
update lnumbers set lncurrent=false where lnid=new.lnid and lncurrent;
endif
return new;
end;' language 'plpgsql';
Dima
---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly