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 1mnYMt-0008AK-SG for pgsql-general@arkaria.postgresql.org; Thu, 18 Nov 2021 03:45: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 1mnYMs-00026t-Oa for pgsql-general@arkaria.postgresql.org; Thu, 18 Nov 2021 03:45:46 +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 1mnYMs-00026k-Bs for pgsql-general@lists.postgresql.org; Thu, 18 Nov 2021 03:45:46 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mnYMp-0001Yg-8I for pgsql-general@lists.postgresql.org; Thu, 18 Nov 2021 03:45:45 +0000 Received: by mail-qk1-x734.google.com with SMTP id d2so4903173qki.12 for ; Wed, 17 Nov 2021 19:45:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=FKKrqd0CGc1tEA593CZsN1y30HUpaqT4v7qLV69xaOo=; b=oDh9v+VxaimqzZcaizZnrMSmMpJdNRraVQS3NwNjdV/902m62W/WYmhTmJcLWcR4df zxqEdV3fWucIL0/RImRwvoURoBs2H+FCfAz/TZnsRXJx1YS43gvzNBVKsjF8UIy6UoXT RrYVXMXG7agkrzbjmPArZr14Uuzm3E5iHcyKsJ6nYr9OsAdYVVko/BnrXczMx17R/HBt 5ZzKyc7lsWJhwEfAw40x0u1HSHPWwun3t5osAMOPfSaghTqq1TnDp7ZZI4YT/teuyN0s o3oxTR8vbdUY1oeVujE3GLssADGz9tmtLHzHsBdGZQzKpWUrUHfpjFfonSm5OAgnF513 8w4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=FKKrqd0CGc1tEA593CZsN1y30HUpaqT4v7qLV69xaOo=; b=jj6sIBcDPS2PqtSxqnYN0TWvUhMw3/FeqNxRATfLwJEBLcAunBc/7Wc/sMMhSNyMgf 0gAi5Ni+tzxF+l7m4MxaEo6WPsxW/0Fl4hV8qtfEgX6q6wQQ7KUElmEUMr7ENoJJX44q lIt3RXWYBPTMnu9fpnDGWDVKhChIfdQBSnc+rt1h4MFoaYMGvwtYGlm9v/WwNIjzAS4K /l0epDC4rf5MOq0JxQoa84UWQaGK/3hTudOnnhNqNxbMSWweT9mJA++rvvUB7mqW1CsD NKh7++AQmXi0EWJh4xzlbcdMpqkmaT1sly1AUK2M1WNHJiOK7QaCHqISyRHwVcyAF0ZI Ptqw== X-Gm-Message-State: AOAM532yQRAggMvdzRHmUWmWTpSYhMMTgPngccwAOsNypI91tGaP9a2S KB8w6JVbA2pDB3uTP4I6zry5XPXUNvs= X-Google-Smtp-Source: ABdhPJzc/QZHfnRd5gqplsM5jt6K1mwUOQpUDlbv3I1CEdkR16PZex5UeQY2L7LVxWKeFyuaOen0oA== X-Received: by 2002:a05:620a:5d:: with SMTP id t29mr17903819qkt.220.1637207141433; Wed, 17 Nov 2021 19:45:41 -0800 (PST) Received: from [192.168.2.100] (pool-72-79-19-93.nwrknj.east.verizon.net. [72.79.19.93]) by smtp.gmail.com with ESMTPSA id f12sm872716qtj.93.2021.11.17.19.45.40 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Nov 2021 19:45:40 -0800 (PST) Message-ID: <87b2142e-276f-bf53-a8e0-f9a84aa9677d@gmail.com> Date: Wed, 17 Nov 2021 22:45:40 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: Postgres Equivalent of Oracle Package Content-Language: en-US To: pgsql-general@lists.postgresql.org References: <494df2a3-5201-33c6-d973-0e7baa09bb20@rodonnell.ie> <826773243.402693.1637083393436@connect.xfinity.com> From: Mladen Gogala In-Reply-To: <826773243.402693.1637083393436@connect.xfinity.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 11/16/21 12:23, DAVID ROTH wrote: > One of the nice things about Oracle packages is that the code is loaded and global values are set and stored only once per session. This is very useful for values that are used repeatedly. > > What is the best way of emulating this behavior in Postgresql? > > You can create a temporary table with "ON COMMIT PRESERVE ROWS", which is visible in a session and cannot cross the session boundary.  Values in the table can be queried throughout the session. That is a pretty good approximation of the session variables in Oracle. -- Mladen Gogala Database Consultant Tel: (347) 321-1217 https://dbwhisperer.wordpress.com