Help with SQL function

From: Jeff Eckermann <jeckermann(at)verio(dot)net>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Help with SQL function
Date: 2001-01-05 15:17:01
Message-ID: 08CD1781F85AD4118E0800A0C9B8580B094871@NEZU
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've sent this twice over the last few days, but it hasn't shown up on the
list. Apologies to any who receive this multiple times.

I'm falling at the first hurdle. Can someone tell me how to pass an
attribute value into a function, as I'm trying to do below? I've studied
the docs every which way, but can't seem to find the cause of my problem.
Thanks in advance for ignorance relief.

extracts=# create function testfunc(text) returns int4 as '
extracts'# select count (*) from dedcolo where equip_type = ''$1'' ---
That's doubled single quotes
extracts'# ' language 'sql';
CREATE
extracts=# select testfunc('Dialup');
testfunc
----------
0
(1 row)
extracts=# create function testfunc() returns int4 as '
extracts'# select count (*) from dedcolo where equip_type = ''Dialup'' ---
Doubled single quotes, again
extracts'# ' language 'sql';
CREATE
extracts=# select testfunc();
testfunc
----------
3453
(1 row)

Browse pgsql-general by date

  From Date Subject
Next Message nfj 2001-01-05 15:30:51 Re: Max connections
Previous Message Ron Peterson 2001-01-05 14:34:25 Re: How passwords can be crypted in postgres?