Re: Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post] - Mailing list pgsql-sql

From Richard Broersma
Subject Re: Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]
Date
Msg-id AANLkTim9K8g6uCEYU95BU2zAZZSUmMr3+Xi96wxsyGYi@mail.gmail.com
Whole thread Raw
In response to Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]  (Axel Rau <Axel.Rau@Chaos1.DE>)
Responses Re: Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]
List pgsql-sql
On Mon, Oct 25, 2010 at 9:07 AM, Axel Rau <Axel.Rau@chaos1.de> wrote:

> I have a function argument blah of type text containing something like
>   33,44,55,66
> . Can I cast it in some way to use it in an IN clause as integers like
>   UPDATE foo SET x = y WHERE id IN ( blah );

Here is what I think should work:

UPDATE foo
Set x = y
WHERE id = ANY( CAST( string_to_array( '1,2,3,4', ',' ) AS INTEGER[] ));


--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug


pgsql-sql by date:

Previous
From: Axel Rau
Date:
Subject: Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]
Next
From: Sergey Konoplev
Date:
Subject: Re: Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]