🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.delphi.bazy-danych
Article #70124

Re: czy mozna programowo wylaczyc triggera w FB

#70124
From: wloochacz
Date: Tue, 12 Jun 2007 13:57
27 lines
1964 bytes
> mam problem - mam trigger ktory nadaje nowemu rekordowi id i oznacza zapis 
> czasem serwera. Okazuje sie jednak ze musze podrzucic dane ze wstecznym 
> czasem. Oczywiscie moge zrobic insert a potem update ale to dlugo potrwa. 
> Czy istnieje mozliwosc czasowego wylaczenia triggera bez jego przebudowy 
> albo zrobienia insertu tak aby trigger nie zadzialal ??
Można dezaktywować, tylko po co w tym przypadku?
IMO lepiej tak:
Jeżeli chcesz zrzucić zapis czasu na trigger to insert tak:
insert into tab(id) values (jakies_id)
Pomijasz czas, czyli de-facto w polu czas będzie null.

Trigger powinien wyglądać tak:
create trigger tab_bi for tab
active before insert
as
begin
   new.czas = coalesce(new.czas, current_timestamp);
end;

Jeśli musisz podmienić czas, to robisz update po prostu (trigger nie 
zadziała bo jest tylko na before insert).
Jezli musisz dodać coś z inną datą niż current_timestamp, to Twój insert 
powinien wyglądać tak:
insert into tab(id, czas) values (jakies_id, jakis_czas)

-- 
wloochacz
Technical Details
Message-ID: <f4m8kv$kg0$1@atlantis.news.tpi.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!nemesis.news.tpi.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
References: <f4ls8s$fql$1@mx1.internetia.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!newsfeed.gazeta.pl!news.nask.pl!news.nask.org.pl!newsfeed.tpinternet.pl!nemesis.news.tpi.pl!atlantis.news.tpi.pl!news.tpi.pl!not-for-mail
From: wloochacz <wl@no.spam>
Newsgroups: pl.comp.lang.delphi.bazy-danych
Subject: Re: czy mozna programowo wylaczyc triggera w FB
Date: Tue, 12 Jun 2007 15:57:13 +0200
Organization: tp.internet - http://www.tpi.pl/
Lines: 27
Message-ID: <f4m8kv$kg0$1@atlantis.news.tpi.pl>
References: <f4ls8s$fql$1@mx1.internetia.pl>
NNTP-Posting-Host: plast-box.pl
Mime-Version: 1.0
X-Trace: atlantis.news.tpi.pl 1181656543 20992 195.205.119.237 (12 Jun 2007 13:55:43 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: Tue, 12 Jun 2007 13:55:43 +0000 (UTC)
User-Agent: Thunderbird 1.5.0.12 (Windows/20070509)
In-Reply-To: <f4ls8s$fql$1@mx1.internetia.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit