Received: from localhost (unknown [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id EACC22E2E8F for ; Sat, 29 Dec 2007 02:40:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 53506-06 for ; Sat, 29 Dec 2007 02:40:03 -0400 (AST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.247]) by postgresql.org (Postfix) with ESMTP id 577052E2DA4 for ; Sat, 29 Dec 2007 02:40:04 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c36so702264ana.33 for ; Fri, 28 Dec 2007 22:40:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=HMxROmI5m+lFVPOc1Fe5hQ1EMTwLStBZQRm0AC2jivU=; b=jDhyWZCxJtD/qPwn+HYKZgpEYAGS49DjKvduwPDKnFMGvnTAPOA0g74yGhdMFKVgTTEzBEnxiSFAIaWJ2/XHo0WRaP5AzlVqSPRBnQUAZjOvOmo7lbWrIC4hbo+dCT4EHhNxg1WVIOnDzd+cVe04ILcY5K3oY2B7Xd81CoO+PQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Z4zYi4Ux+fiUm9G+wAHsao4qrVQHHdAXWqj+R1I6uBxCqFY6+kPahBFOB1eHfGuLrC453Cyte1/qa4dDELUw3PQ+sO58jqmdQezyYvyip9sxJkIaum7Rc6fDyHkav6BJ7Z90VZ78hegUN0twfXL3XX/oYkuEeFM2RPXMd2/zr3I= Received: by 10.100.255.10 with SMTP id c10mr20835762ani.54.1198910403061; Fri, 28 Dec 2007 22:40:03 -0800 (PST) Received: by 10.100.214.10 with HTTP; Fri, 28 Dec 2007 22:40:03 -0800 (PST) Message-ID: <455d64770712282240h3c93a2f0y9e357d1d23882b10@mail.gmail.com> Date: Sat, 29 Dec 2007 01:40:03 -0500 From: "Daniel Myers" To: pgsql-sql@postgresql.org Subject: PL/pgsql: function passing argument to IN operator MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/148 X-Sequence-Number: 29840 Hello list, I'm trying to write a function that uses one of its arguments as an input to an IN operator in a WHERE clause. I.e., something like: -- ids are actually integers CREATE FUNCTION foo(ids SOMETYPE) RETURNS [whatever] AS $$ BEGIN SELECT id, [other stuff] FROM table WHERE [other conditions] AND id IN (ids); RETURN; END $$ plpgsql I had wanted to avoid using the EXECUTE statement and dynamically creating the query string, because 1) I'd rather not recompile the query each time and 2) I'm doing a SELECT INTO, which apparently doesn't work with EXECUTE. Can anyone help me out? Thanks, Daniel P.S.: Sorry if capitalizing SQL keywords is bad list etiquette...