RE: Help with SQL Function

From: Jeff Eckermann <jeckermann(at)verio(dot)net>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: RE: Help with SQL Function
Date: 2001-01-08 17:17:07
Message-ID: 08CD1781F85AD4118E0800A0C9B8580B09487D@NEZU
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks, Tom, and also to Alex Pilosov for his answer.
I was extrapolating from the plpgsql docs, which I probably didn't
understand correctly.
Programming By Example (which is what we non-programmers are obliged to do)
doesn't work so well when the docs are somewhat sparse.
Are there any plans to expand the docs on plpgsql, since there are new
features coming? Plpgsql looks like a good tool for enhancing my
development of financial etc reports, but in working with it, I've had two
weeks of frustration and not much of anything else so far.

> -----Original Message-----
> From: Tom Lane [SMTP:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Saturday, January 06, 2001 3:41 PM
> To: Jeff Eckermann
> Cc: pgsql-general(at)postgresql(dot)org
> Subject: Re: [GENERAL] Help with SQL Function
>
> 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

Browse pgsql-general by date

  From Date Subject
Next Message Mikheev, Vadim 2001-01-08 17:19:30 RE: backend corruption
Previous Message Lamar Owen 2001-01-08 16:29:56 Re: Version 7.1 when??