Jump to content
php.lv forumi

postgre funkcijas


Kristabs

Recommended Posts

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

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 by Delfins
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...