Re: Help with SQL Function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Eckermann <jeff(at)akira(dot)eckermann(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Help with SQL Function
Date: 2001-01-06 21:40:35
Message-ID: 18661.978817235@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Eckermann <jeff(at)akira(dot)eckermann(dot)com> writes:
> 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

That's looking for rows where equip_type = '$1' ... ie, the literal
string $1. What you probably wanted is

create function testfunc(text) returns int4 as '
select count (*) from dedcolo where equip_type = $1
' language 'sql';

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2001-01-06 21:43:22 Re: Postgres 7.03 table describe problem
Previous Message Alex Pilosov 2001-01-06 21:40:15 Re: Help with SQL Function