Help with SQL function - Mailing list pgsql-general

From Jeff Eckermann
Subject Help with SQL function
Date
Msg-id 08CD1781F85AD4118E0800A0C9B8580B094871@NEZU
Whole thread Raw
List 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)



pgsql-general by date:

Previous
From: "ineck"
Date:
Subject: Warning: PostgresSQL query failed????`
Next
From: "Ian deSouza"
Date:
Subject: Re: DROP SEQUENCE ?