dbTalk Databases Forums  

[BUGS] Concatenating strings within a function definition

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Concatenating strings within a function definition in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Nishad Prakash
 
Posts: n/a

Default [BUGS] Concatenating strings within a function definition - 11-04-2004 , 01:31 PM







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


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Concatenating strings within a function definition - 11-04-2004 , 01:46 PM






Nishad Prakash <prakashn (AT) uci (DOT) edu> writes:
Quote:
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';
'select lid from ilemma where lemma ~ (\'^\' || upper($1))'

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.