Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ikTmD-0005WC-Rh for pgsql-general@arkaria.postgresql.org; Thu, 26 Dec 2019 14:06:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ikTmC-0006lH-Lx for pgsql-general@arkaria.postgresql.org; Thu, 26 Dec 2019 14:06:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ikTmC-0006l9-7c for pgsql-general@lists.postgresql.org; Thu, 26 Dec 2019 14:06:08 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ikTmA-0000LB-1H for pgsql-general@lists.postgresql.org; Thu, 26 Dec 2019 14:06:07 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id xBQE63bA017329; Thu, 26 Dec 2019 09:06:03 -0500 From: Tom Lane To: stan cc: pgsql-general@lists.postgresql.org Subject: Re: What am I doing wrong here? In-reply-to: <20191226133639.GA15506@panix.com> References: <20191226133639.GA15506@panix.com> Comments: In-reply-to stan message dated "Thu, 26 Dec 2019 08:36:39 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <17327.1577369163.1@sss.pgh.pa.us> Date: Thu, 26 Dec 2019 09:06:03 -0500 Message-ID: <17328.1577369163@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk stan writes: > When I try to insert this function I get an error on the following line: > _bom_name_key = ( SELECT > I actually pretty much get a syntax error whatever is at this line. > Can someone please explain what I am doing wrong? I think you're misunderstanding where to put the WITH. That's just part of the SQL statement as far as plpgsql is concerned, so what you need to do to use a WITH clause in a variable assignment is to write variable := WITH ... SELECT ... ; (At least, I think that will work; what you're doing definitely won't.) regards, tom lane