Help with SQL Function

From: Jeff Eckermann <jeckermann(at)verio(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Help with SQL Function
Date: 2001-01-03 22:30:04
Message-ID: 08CD1781F85AD4118E0800A0C9B8580B09486F@NEZU
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shterke Seben 2001-01-03 22:39:40 Problems about extracting data with cgi's
Previous Message Tom Lane 2001-01-03 21:24:43 Re: user privileges for particular table