pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jure Kobal <j.kobal@gmx.com>
To: pgsql-sql@postgresql.org, landsharkdaddy <ldodd@landsharksoftware.com>
Subject: Re: Query with Parameters and Wildcards
Date: Mon, 27 Apr 2009 18:29:26 +0200
Message-ID: <200904271829.26557.j.kobal@gmx.com> (raw)
In-Reply-To: <487E9B6FF30F43DFB2DC0B00E81DAF7A@dayatPC>
References: <23248274.post@talk.nabble.com>
	<23257346.post@talk.nabble.com>
	<487E9B6FF30F43DFB2DC0B00E81DAF7A@dayatPC>

In the original select you missed a small part. The operation || needs a value 
on every side and you missed the value on the left side. You had it as: WHERE 
(customerlastname ILIKE || '%') instead of WHERE (customerlastname 
ILIKE 'lastname' || '%'). And that is the reason for the error you got.

The function from dayat has a small mistake. It should be:
CREATE OR REPLACE FUNCTION TEST(lastname VARCHAR)
else it will result in an error because of the missing space.

On Monday 27 of April 2009 16:47:40 dayat wrote:
> Do you run this code in the function? If so, the following example function
> with LANGUAGE SQL function:
>
> CREATE OR REPLACE FUNCTION TEST(lastnameVARCHAR)
> RETURNS SETOF lanemanager.customers
> AS $$
> SELECT customercellphone, customercity, customerdatecreated,
> customerdatelastmodified, customeremail, customerfax, customerfirstname,
> customerid, customerlastname, customermiddleinitial, customerphone,
> customerreferredby, customerstateabbr, customerstreet1, customerstreet2,
> customersuffix, customertitle, customerworkphone, customerworkphoneext,
> customerzip FROM lanemanager.customers WHERE (customerlastname ILIKE $1 ||
> '%')
> $$
> LANGUAGE SQL;
>
> Please tell me is it work for you.
>
> Regards
> Hidayat
>
> ----- Original Message -----
> From: "landsharkdaddy" <ldodd@landsharksoftware.com>
> To: <pgsql-sql@postgresql.org>
> Sent: Monday, April 27, 2009 9:19 PM
> Subject: Re: [SQL] Query with Parameters and Wildcards
>
> > When I try the following like you suggested I get an error that says
> > "operator does not exist: || unknown
> >
> >
> >
> > SELECT customercellphone, customercity, customerdatecreated,
> > customerdatelastmodified, customeremail, customerfax, customerfirstname,
> > customerid, customerlastname, customermiddleinitial, customerphone,
> > customerreferredby, customerstateabbr, customerstreet1, customerstreet2,
> > customersuffix, customertitle, customerworkphone, customerworkphoneext,
> > customerzip FROM lanemanager.customers WHERE (customerlastname ILIKE ||
> > '%')
> >
> > landsharkdaddy wrote:
> >> I have a query that works on SQL Server to return customers that contain
> >> the string entered by the user by accepting parameters and using the
> >> LIKE keyword. I would like to move this to postgreSQL but I'm just not
> >> sure how
> >> to get it done. This is the query
> >>
> >> SELECT * FROM Customers WHERE FirstName LIKE @custfirst + '%';
> >>
> >> This works great on SQL Server but not on postgreSQL. Any help would be
> >> appreciated.
>
> __________________________________________________
> Apakah Anda Yahoo!?
> Lelah menerima spam?  Surat Yahoo! memiliki perlindungan terbaik terhadap
> spam http://id.mail.yahoo.com



view thread (10+ messages)  latest in thread

Message-ID: <200904271829.26557.j.kobal@gmx.com>
Permalink:  ../200904271829.26557.j.kobal@gmx.com/
Also on:    postgresql.org/message-id/200904271829.26557.j.kobal@gmx.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: j.kobal@gmx.com, ldodd@landsharksoftware.com
  Subject: Re: Query with Parameters and Wildcards
  In-Reply-To: <200904271829.26557.j.kobal@gmx.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox