Re: Functional dysfunction
| От | Tom Lane |
|---|---|
| Тема | Re: Functional dysfunction |
| Дата | |
| Msg-id | 1506.964818187@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Functional dysfunction (ERIC Lawson - x52010 <eric@bioeng.washington.edu>) |
| Ответы |
Re: Functional dysfunction
|
| Список | pgsql-novice |
ERIC Lawson - x52010 <eric@bioeng.washington.edu> writes:
> create function matRelat(text)
> returns setof ADR as
> 'select ln from ADR where
> nsrrelat01 ~* \'$1\'::text or
> nsrrelat02 ~* \'$1\'::text or
> nsrrelat03 ~* \'$1\'::text or
> nsrrelat04 ~* \'$1\'::text;'
> language 'sql';
Seems to me you want "returns setof TEXT" or whatever the datatype of ln
is. "setof ADR" implies it returns the whole tuple (that would be
appropriate if you wanted "select * from ADR where ...").
Beware that functions returning sets are not all that well supported;
they work in simple examples like "select function(...)" but you can't
really combine them in expressions.
Have you thought about a view? Perhaps
create view v1 as select ln, nsrrelat01 || ' ' || nsrrelat02 || ' ' ||
nsrrelat03 || ' ' || nsrrelat04 as nsrrelat;
and then
select ln from v1 where nsrrelat ~* 'foo';
regards, tom lane
В списке pgsql-novice по дате отправления: