Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rblLc-00GroG-Bk for pgsql-general@arkaria.postgresql.org; Sun, 18 Feb 2024 17:53:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rblLa-00AeZ9-Nu for pgsql-general@arkaria.postgresql.org; Sun, 18 Feb 2024 17:53:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rblLa-00AeZ0-Ch for pgsql-general@lists.postgresql.org; Sun, 18 Feb 2024 17:53:02 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rblLX-007OeI-U0 for pgsql-general@lists.postgresql.org; Sun, 18 Feb 2024 17:53:01 +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 41IHqxeg3883446; Sun, 18 Feb 2024 12:52:59 -0500 From: Tom Lane To: Laura Smith cc: postgre Subject: Re: Function inserting into tstzrange ? (syntax error at or near...) In-reply-to: <5Tfn0cxmVyZ3uSyl4_GqlisTneXWCuH0I5Jk6PgEGtFXkBGlTXiXfT8ffk1YyF1zhGoGOxdpmpOPvOQfK4l74T4fK8xKMxTHcs-J_08M8j4=@protonmail.ch> References: <5Tfn0cxmVyZ3uSyl4_GqlisTneXWCuH0I5Jk6PgEGtFXkBGlTXiXfT8ffk1YyF1zhGoGOxdpmpOPvOQfK4l74T4fK8xKMxTHcs-J_08M8j4=@protonmail.ch> Comments: In-reply-to Laura Smith message dated "Sun, 18 Feb 2024 17:40:57 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3883444.1708278779.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 18 Feb 2024 12:52:59 -0500 Message-ID: <3883445.1708278779@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laura Smith writes: > I'm sure I'm doing something stupid here, but I think I've got the synta= x right ? > The error I'm seeing: > psql:event_session_funcs.sql:26: ERROR: =C2=A0syntax error at or near "[= " > LINE 11: =C2=A0 =C2=A0 =C2=A0 =C2=A0 VALUES(p_event_id,[p_start_time,p_e= nd_time)) RETURNI... There's not bespoke SQL syntax for constructing a range. You must use a function, something like VALUES(p_event_id, tstzrange(p_start_time,p_end_time,'[)')) ... although I believe '[)' is the default bounds type so that could be simplified to VALUES(p_event_id, tstzrange(p_start_time,p_end_time)) ... regards, tom lane