Kristabs Posted April 7, 2005 Report Share Posted April 7, 2005 nu jau kaadu laiku censhos dazhas funkcijas postgresql uzrakstiit, bet bez sekmeem. Vai kaads vareetu uzrakstiit piemeeram funkciju - "update tabula2 set laiks = tabula1.laiks where id = tabula1.id", respektiivi trigeris izsauks sho funkciju on update tabula1.laiks un funkcija sho pashu laiku ierakstiis arii tabula2 laukaa laiks. (date, integer) Link to comment Share on other sites More sharing options...
Delfins Posted April 8, 2005 Report Share Posted April 8, 2005 (edited) nu jau kaadu laiku censhos dazhas funkcijas postgresql uzrakstiit, bet bez sekmeem. Vai kaads vareetu uzrakstiit piemeeram funkciju - "update tabula2 set laiks = tabula1.laiks where id = tabula1.id", respektiivi trigeris izsauks sho funkciju on update tabula1.laiks un funkcija sho pashu laiku ierakstiis arii tabula2 laukaa laiks.(date, integer) 16105[/snapback] ai cik daudz piemēru internetā. pat dokumentācijā tas viss ir... CREATE OR REPLACE FUNCTION flights_update_trg_fnc() RETURNS "trigger" AS $BODY$declare begin INSERT INTO flights_changes(id,new_destination,old_destination,time) VALUES( old.id, new.destination, old.destination, now() ); RETURN new; end;$BODY$ LANGUAGE 'plpgsql' VOLATILE; ALTER FUNCTION flights_update_trg_fnc() OWNER TO some_user; CREATE TRIGGER flights_update_trg AFTER UPDATE ON flights FOR EACH ROW EXECUTE PROCEDURE flights_update_trg_fnc(); Edited April 8, 2005 by Delfins Link to comment Share on other sites More sharing options...
Kristabs Posted April 8, 2005 Author Report Share Posted April 8, 2005 sleegts Link to comment Share on other sites More sharing options...
Recommended Posts