Re: tsearch2() with data from other table

From: Marcus Engene <mengpg(at)engene(dot)se>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: tsearch2() with data from other table
Date: 2006-11-10 14:28:02
Message-ID: 45548C72.4050703@engene.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Teodor Sigaev skrev:
>> CREATE FUNCTION euits(int)
>> RETURNS text AS 'select username || \' \' || firstname || \' \' ||
>> lastname from site_user where objectid = $1;' LANGUAGE SQL;
>>
>> CREATE TRIGGER site_item_fts
>> BEFORE UPDATE OR INSERT ON site_item
>> FOR EACH ROW EXECUTE PROCEDURE
>> tsearch2(idxfti, name, keywords, keywords_cb, location_country,
>> location_city, media_source, description, euits, site_user);
>
> site_user is a table, isn't it?
> tsearch2 trigger accepts only column's names and functions with
> prototype TEXT func(TEXT).
>
> For clarify, show your table's definitions.

Hi,

I'm sorry I was unclear,

create table site_user
(
objectid integer
,firstname varchar[60]
,lastname varchar[60]
,username varchar[10]
...
) without oids;

create table site_item
(
objectid integer
,site_user integer -- fk to site_user.objectid
,description text
,idxfti tsvector
...
) without oids;

So, when updating site_item I want to fetch the names from site_user and
give this data to tsearch2() along with other stuff from site_item.

Best regards,
Marcus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeremiasz Miedzinski 2006-11-10 14:37:01 Re: [PL/pgSQL] Commit every N rows. Is it possible ?
Previous Message Alexander Staubo 2006-11-10 14:24:58 Using GIN indexes on 8.2