Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WHr7M-0000Pj-6W for pgsql-sql@arkaria.postgresql.org; Mon, 24 Feb 2014 08:42:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WHr7K-0005wc-Vt for pgsql-sql@arkaria.postgresql.org; Mon, 24 Feb 2014 08:42:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WHr7I-0005wT-W6 for pgsql-sql@postgresql.org; Mon, 24 Feb 2014 08:42:25 +0000 Received: from gw03.mail.saunalahti.fi ([195.197.172.111]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WHr7F-00033z-P8 for pgsql-sql@postgresql.org; Mon, 24 Feb 2014 08:42:24 +0000 Received: from cfwo-22.mail.saunalahti.fi (cfwo-22.mail.saunalahti.fi [62.142.5.121]) by gw03.mail.saunalahti.fi (Postfix) with ESMTP id 41F3D2804A for ; Mon, 24 Feb 2014 10:42:21 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by cfwo-22.mail.saunalahti.fi (Postfix) with ESMTP id 0FB1020076 for ; Mon, 24 Feb 2014 10:42:21 +0200 (EET) X-Spam-Checker-Version: SpamAssassin 3.3.2-saunamods_5.22 (2011-06-06) on cfwo-22.mail.saunalahti.fi X-Spam-Level: X-Spam-Status: No, score=0.0 required=7.0 tests=none shortcircuit=no autolearn=no version=3.3.2-saunamods_5.22 Received: from tarazed.webmail.wippies.com (tarazed.webmail.wippies.com [195.197.55.111]) by cfwo-22.mail.saunalahti.fi (Postfix) with ESMTP id C35D820072 for ; Mon, 24 Feb 2014 10:42:20 +0200 (EET) Date: Mon, 24 Feb 2014 10:42:20 +0200 (EET) From: Pena Kupen To: pgsql-sql@postgresql.org Message-ID: <1750529416.3096311393231340773.JavaMail.kupen@wippies.fi> Subject: array in function MIME-Version: 1.0 Content-Type: text/plain; Charset=iso-8859-1; Format=Flowed Content-Transfer-Encoding: quoted-printable X-Mailer: Saunalahti webmail - http://saunalahti.fi X-Originating-IP: 87.100.207.98 X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Hi, I have a problem with function, where I want to use execute and create sql = for it. My table is: create table types ( id integer, type_id character varying, explain character varying ); And function: CREATE or REPLACE FUNCTION hasType(_list character varying[]) RETURNS integ= er LANGUAGE plpgsql AS $$ DECLARE hasValue integer; BEGIN EXECUTE 'SELECT 1 FROM types WHERE type_id ANY('|| _list ||') ' INTO hasVa= lue; IF hasValue IS NULL THEN RETURN 0; ELSE RETURN 1; END IF;=09=09=09=09=09=09=09 END; $$; Executing function with array parameter: select hasType(ARRAY['E','F','','']); I got error: SQL error: ERROR: operator is not unique: unknown || character varying[] at character= 49 HINT: Could not choose a best candidate operator. You might need to add ex= plicit type casts. QUERY: SELECT 'SELECT 1 FROM types WHERE type_id ANY('|| $1 ||') ' CONTEXT: PL/pgSQL function "hastype" line 4 at EXECUTE statement In statement: select hasType(ARRAY['E','F','','']); How to add array in parameter list to sql-sentence? -kupen --=20 Wippies-vallankumous on t=E4=E4ll=E4! Varmista paikkasi vallankumouksen etu= rintamassa ja liity Wippiesiin heti! http://www.wippies.com/ --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql