Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 04E26632F2A for ; Wed, 26 Aug 2009 11:14:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 24137-10 for ; Wed, 26 Aug 2009 14:14:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f207.google.com (mail-ew0-f207.google.com [209.85.219.207]) by mail.postgresql.org (Postfix) with ESMTP id CFACA632453 for ; Wed, 26 Aug 2009 11:14:01 -0300 (ADT) Received: by ewy3 with SMTP id 3so194246ewy.42 for ; Wed, 26 Aug 2009 07:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=9A5XttUg9usanpFjPli8n6AyRob7mgxWN9cXeJCh+Dg=; b=DlYUxpC39lNrcveAU28P1YtgW7kxiAIqi/U/5JidCUzOUOGhglOCzdCiOzlIYleCur LrqVH2FVIoAwcGvVpmA0B4/XvIRtr3BvfnycHT15TPYuVnveP5t9zjvUsSxr+xlRb11Y 6y6+3eM3Va5sHjUbpFFPGpCtA/lLRgTHw9SJc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=n2kbCaW1iHNSshvPR5ZDBy5duUYfKpnZuHAC3bv3OL1le5xLLoTml4pJB5wK7GApRk /I+t+ZmA9FQ3GHkvQX1SSfGNf9d3PNdQFjWcreSoTE0UnF29YtaIa41QqfTHdgP+oHDV EdOPVfsacx/MDMYfRki7AojdYJ7yq1Lj0dRFc= MIME-Version: 1.0 Received: by 10.216.28.15 with SMTP id f15mr1668385wea.30.1251296039093; Wed, 26 Aug 2009 07:13:59 -0700 (PDT) In-Reply-To: <11645.1251295508@sss.pgh.pa.us> References: <20090826133036.GK32599@a-kretschmer.de> <11645.1251295508@sss.pgh.pa.us> From: Nacef LABIDI Date: Wed, 26 Aug 2009 15:13:39 +0100 Message-ID: Subject: Re: Selecting values from comma separated string To: Tom Lane Cc: "A. Kretschmer" , pgsql-sql@postgresql.org Content-Type: multipart/alternative; boundary=00504502d2f6eb44a504720c0f3f X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.598 tagged_above=-10 required=5 tests=BAYES_00=-2.599, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200908/132 X-Sequence-Number: 33041 --00504502d2f6eb44a504720c0f3f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Here I come again to ask how can I pass an array of values to a pgsql function when I call this function from a delphi program for example. Nacef On Wed, Aug 26, 2009 at 3:05 PM, Tom Lane wrote: > "A. Kretschmer" writes: > > In response to Nacef LABIDI : > >> I want to write a function that takes as param a comma separated values > string > >> and perform a select matching these values. > > > Use EXECUTE sql_string, > > Safer to use string_to_array, for instance > > ... WHERE id = ANY(string_to_array('1,3,7,8', ',')::int[]) ... > > Of course this just begs the question of why the OP doesn't use an > array in the first place. > > regards, tom lane > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > -- Nacef LABIDI nacef.l@gmail.com --00504502d2f6eb44a504720c0f3f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Here I come again to ask how can I pass an array of values= to a pgsql function when I call this function from a delphi program for ex= ample.

Nacef



On Wed, Aug = 26, 2009 at 3:05 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
"A. Kretschmer" <andreas.kretschmer@schollglas.com> writes:
> In response to Nacef LABIDI :
>> I want to write a function that takes as p= aram a comma separated values string
>> and perform a select matching these values.

> Use EXECUTE sql_string,

Safer to use string_to_array, for instance

=A0 =A0 =A0 =A0... WHERE id =3D ANY(string_to_array('1,3,7,8', = 9;,')::int[]) ...

Of course this just begs the question of why the OP doesn't use an
array in the first place.

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0regards, tom lane

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
= http://www.postgresql.org/mailpref/pgsql-sql



--
Nacef LABID= I
nacef.l@gmail.com
--00504502d2f6eb44a504720c0f3f--