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 1n54BF-0005Mf-6P for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 11:10:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n54BE-00079W-4V for pgsql-general@arkaria.postgresql.org; Wed, 05 Jan 2022 11:10:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n54BD-00079N-QR for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 11:10:07 +0000 Received: from srv01.teladesign.ie ([2001:41c9:1:41d::10]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n54BB-00082l-KG for pgsql-general@lists.postgresql.org; Wed, 05 Jan 2022 11:10:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rodonnell.ie; s=exim; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:References:To:From:Subject:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Message-ID; bh=I1K+C1fq+kNXqQmz6Owq0Il0tHq56HY1xMrhHJo+8mQ=; b=FuO9dFjQ9mbG3xN2gVmToYFVf3 li52MXhwQL6Fu1ZrP02jxgoBLAeU8w+Busoe8RmZPYPFOKxR5/NXo8lRRw3JGiCURiBClF0jlgC1F 8jEey9DMU3NvhYI6NpULzigupVd5uzgOcAULxgdAtgQH0dF1fWUdINl3CS/paXV4Dni8=; Received: from [93.107.231.214] (helo=[192.168.1.15]) by srv01.teladesign.ie with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n54B9-0006Bs-GA; Wed, 05 Jan 2022 11:10:03 +0000 Subject: Re: Can we use sql language to create a function in Postgres? From: Ray O'Donnell To: Shaozhong SHI , pgsql-general References: <3716cb3b-21e9-a204-1b2c-37a4f023c72f@rodonnell.ie> Message-ID: Date: Wed, 5 Jan 2022 11:10:02 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <3716cb3b-21e9-a204-1b2c-37a4f023c72f@rodonnell.ie> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Spam-Bar: / List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 05/01/2022 11:08, Ray O'Donnell wrote: > On 05/01/2022 11:04, Shaozhong SHI wrote: >> I was given an Oracle script.  Can we use sql language to create a >> function in Postgres? > > Yes, absolutely: > > create function my_function(...) > as > $$ >   select..... > $$ > language sql; Should have added the link to the docs: https://www.postgresql.org/docs/14/server-programming.html Ray. -- Raymond O'Donnell // Galway // Ireland ray@rodonnell.ie