Converting string to IN query

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Converting string to IN query
Date: 2008-09-12 13:27:27
Message-ID: gadqof$2845$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

String contains list of document numbers (integers) like:

'1,3,4'

How to SELECT documents whose numbers are contained in this string.
I tried

create temp table invoices ( invoiceno int );
insert into invoices values (1);
insert into invoices values (2);
insert into invoices values (3);
insert into invoices values (4);
SELECT * FROM invoices WHERE invoiceno IN ( '1,3,4' );

but this causes error.

Numbers should be passed as single string literal since FYIReporting
RDLEngine does not allow multivalue parameters.

How to fix this so that query returns invoices whose numbers are contained
in string literal ?
Can arrays used to convert string to list or any other solution ?

Andrus.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jack Orenstein 2008-09-12 13:51:51 Re: Autocommit, isolation level, and vacuum behavior
Previous Message Peter Eisentraut 2008-09-12 07:22:02 Re: psql scripting tutorials