2010-04-10 16 views
0
CONTENT_TABLE 
id | author | timestamp | title | description 
----+-----------------+-----------+----------------+---------------------- 
(0 rows) 

SEARCH_TABLE 
id | content_type_id | object_id | tsvector_title | tsvector_description 
----+-----------------+-----------+----------------+---------------------- 
(0 rows) 

我有當過CONTENT_TABLE更新爲引發觸發器/ INSERTED射擊Postgres的觸發不同的表列

事情是這樣的:

"CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON course_course FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(SHOULD_BE_THE_COLUMN_OF_SEARCH_TABLE(tsvector_description), 'pg_catalog.english', description);" 
  • 其實,我要補充的tsvector標題和CONTENT_TABLE到表SEARCH_TABLE tsvector_title和tsvector_description的描述。我可以爲它啓動一個觸發器嗎?

任何形式的幫助將不勝感激。提前致謝。

回答

3

默認的tsvector_update_trigger不能查看另一個表。但是如果你自己寫(例如pl/pgsql),你可以很容易地做到這一點。請參閱http://www.postgresql.org/docs/8.4/static/plpgsql-trigger.html。您只需要收集數據並將函數調用to_tsvector(),並將結果粘貼到tsvector列中。