Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJLwp-0003r8-LC for pgsql-general@arkaria.postgresql.org; Mon, 08 Mar 2021 19:53:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lJLwn-0006he-UT for pgsql-general@arkaria.postgresql.org; Mon, 08 Mar 2021 19:53:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJLwn-0006hX-Mr for pgsql-general@lists.postgresql.org; Mon, 08 Mar 2021 19:53:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lJLwl-0002Ub-OT for pgsql-general@postgresql.org; Mon, 08 Mar 2021 19:53:45 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 128JrfsM1842233; Mon, 8 Mar 2021 14:53:41 -0500 From: Tom Lane To: Alexander Farber cc: pgsql-general Subject: Re: Stored function RETURNS table, but in some cases columns are missing - should I set them to NULL? In-reply-to: References: Comments: In-reply-to Alexander Farber message dated "Mon, 08 Mar 2021 19:20:09 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1842231.1615233221.1@sss.pgh.pa.us> Date: Mon, 08 Mar 2021 14:53:41 -0500 Message-ID: <1842232.1615233221@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alexander Farber writes: > However there are cases, when I only have the out_gid value, I do not want > to return any other values. > My question is: do I have to set the other OUT params explicitly to NULL? plpgsql initializes them to null by default, I believe, just like ordinary local variables. > org.postgresql.util.PSQLException: ERROR: column "out_uid" does not exist| This isn't related to what your function does internally. I think the issue is you renamed out_uid to uid in your SELECT: > String SQL_JOIN_GAME = > "SELECT " + > "out_uid AS uid, " + regards, tom lane