pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: A. Kretschmer <andreas.kretschmer@schollglas.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Selecting values from comma separated string
Date: Wed, 26 Aug 2009 10:05:08 -0400
Message-ID: <11645.1251295508@sss.pgh.pa.us> (raw)
In-Reply-To: <20090826133036.GK32599@a-kretschmer.de>
References: <f16f7ea00908260619t59555d37u66bebfe47132304f@mail.gmail.com>
	<20090826133036.GK32599@a-kretschmer.de>

"A. Kretschmer" <andreas.kretschmer@schollglas.com> 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



view thread (7+ messages)  latest in thread

Message-ID: <11645.1251295508@sss.pgh.pa.us>
Permalink:  ../11645.1251295508@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/11645.1251295508@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, andreas.kretschmer@schollglas.com
  Subject: Re: Selecting values from comma separated string
  In-Reply-To: <11645.1251295508@sss.pgh.pa.us>

* 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