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 1meIB0-0005Gx-Qb for pgsql-sql@arkaria.postgresql.org; Sat, 23 Oct 2021 14:39:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1meIAz-0003hM-Gn for pgsql-sql@arkaria.postgresql.org; Sat, 23 Oct 2021 14:39:13 +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 1meIAz-0003gF-8H for pgsql-sql@lists.postgresql.org; Sat, 23 Oct 2021 14:39:13 +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 1meIAs-0004N0-VC for pgsql-sql@lists.postgresql.org; Sat, 23 Oct 2021 14:39:12 +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 19NEd35c3094023; Sat, 23 Oct 2021 10:39:03 -0400 From: Tom Lane To: aditya desai cc: "Voillequin, Jean-Marc" , pgsql-sql Subject: Re: Convert text to user defined datatype In-reply-to: References: Comments: In-reply-to aditya desai message dated "Sat, 23 Oct 2021 20:01:52 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3094021.1634999943.1@sss.pgh.pa.us> Date: Sat, 23 Oct 2021 10:39:03 -0400 Message-ID: <3094022.1634999943@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk aditya desai writes: > Thanks Jean. However I am trying this inside procedure and getting an > error. Will try to send screenshot. That's frowned on around here. Can't you copy-and-paste the code and the error message? As Jean-Marc says, you shouldn't really need a defined CAST object to cast to or from text; Postgres will interpret that as a request to apply the datatype's I/O functions. You can formalize that by creating a cast "WITH INOUT", but you shouldn't need to, so I think your problem here is something different from what you said. Hard to give more advice without seeing the problem code and the specific error. regards, tom lane