[SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause

2010-10-29 Thread Axel Rau
Good morning, 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 ); or need I revert to dynamic SQL (EXECUTE...) ? Thanks, Axel ---

Re: [SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause

2010-10-29 Thread Dmitriy Igrishin
Hey Axel, How about this solution: UPDATE foo SET x = y WHERE ANY(string_to_array(blah, ',')) = id; ? 2010/10/25 Axel Rau axel@chaos1.de Good morning, 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

Re: [SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause

2010-10-29 Thread Dmitriy Igrishin
Ooops, sorry UPDATE foo SET x = y WHERE id = ANY(string_to_array(blah, ',')::integer[]); 2010/10/29 Dmitriy Igrishin dmit...@gmail.com Hey Axel, How about this solution: UPDATE foo SET x = y WHERE ANY(string_to_array(blah, ',')) = id; ? 2010/10/25 Axel Rau axel@chaos1.de Good

[SQL] Using PL/pgSQL text argument in 'IN (INT,INT,...)' clause [re-post]

2010-10-25 Thread Axel Rau
Good morning, 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 ); or need I revert to dynamic SQL (EXECUTE...) ? Thanks, Axel ---

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

2010-10-25 Thread Richard Broersma
On Mon, Oct 25, 2010 at 9:07 AM, Axel Rau axel@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

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

2010-10-25 Thread Sergey Konoplev
Hi, You can do this: UPDATE foo SET x = y WHERE id = ANY(string_to_array(blah, ',')::integer[]); Note that you need to cast string_to_array(...) to array type of your id type. On 25 October 2010 20:07, Axel Rau axel@chaos1.de wrote: Good morning, I have a function argument blah of type

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

2010-10-25 Thread Axel Rau
Thanks Richard and Sergey, your solution works perfect, even if blah contains only one member. Am 25.10.2010 um 18:17 schrieb Richard Broersma: 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[] )); Axel ---