Concatenating strings within a function definition

From: Nishad Prakash <prakashn(at)uci(dot)edu>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Concatenating strings within a function definition
Date: 2004-11-04 19:18:56
Message-ID: Pine.GSO.4.58.0411041109160.27376@e4e.oac.uci.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


I'm trying to create a function like so:

create function get_lid_prefix (text) returns setof int as
'select lid from ilemma where lemma ~ \'^\' + upper($1)'
language 'sql';

I've tried several variations, including

'select lid from ilemma where lemma ~ ' || '^' || ' upper ($1)'

'select lid from ilemma where lemma ~ (cast ''^'' as text) || upper ($1)'

but nothing works. Can I do this at all? The idea is that if $1 is
"foo", the query should be

select lid from ilemma where lemma ~ '^FOO'

I'm running PostgreSQL 7.4 on sparc-sun-solaris2.8, compiled by GCC 3.0.4.

Thanks,

Nishad
--
"Underneath the concrete, the dream is still alive" -- Talking Heads

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-11-04 19:32:42 Re: Concatenating strings within a function definition
Previous Message Tom Lane 2004-11-04 18:23:15 Re: could not find /usr/local/timezone