Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGXaJ-0004jC-0R for pgsql-sql@arkaria.postgresql.org; Thu, 01 Jun 2017 21:24:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dGXaI-0004jT-Ja for pgsql-sql@arkaria.postgresql.org; Thu, 01 Jun 2017 21:24:46 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dGXaH-0004ex-Dp for pgsql-sql@postgresql.org; Thu, 01 Jun 2017 21:24:45 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dGXaA-0001kM-Ig for pgsql-sql@postgresql.org; Thu, 01 Jun 2017 21:24:44 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 9A65120A66; Thu, 1 Jun 2017 17:24:37 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Thu, 01 Jun 2017 17:24:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=BbNlSiGbi23JkOt1L1 tEh151OaxZbR+fQJ6IXS1kpLc=; b=N09dOkD6kY4S9JvuwTekdkc9kfHjz4qVPH R4UP+7Fr91di+qjgrS5+LLFlizTrCHwvNwKmAw3zlPWmEZX0HNUmdth5/+rFPkhQ XAGgpSVzCInDAUDMlOACchCIrwjvqsE5piMktnqYwo32GeTPe/usJaenI6rIyoUG HvqyXPcebpkiPkxjnSZ2SHWjmw8JZkIg6Jy+DIRaHY0cKdVrZVmD1cqZjQ34kMhV x0y9gItwWi7+tbW+9LMTPaTostqZ8Uk4Kwl7kYVkEhirbagkJndhln3enfYgNvLv XtrHvem7s2jcJIDZ4KjhNUYoUQWllbooZee/5hRJFxqBdypS6FRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=BbNlSiGbi23JkOt1L1tEh151OaxZbR+fQJ6IXS1kpLc=; b=rGp5cuo0 OEuywG6Q1tVpqTwitGwKLDmeJpYkrFgiv2hzPGcjIQxgU/g90Cma1kXFMyeQ69sG Aub09rwPlNU1WPXcU0T1SQXvk5QBNMJVvHBiVFvwHbXiB10zEmmsViPdtxVOX/5F vqenZpqahxM/OXipjmt1HqFYwxbfphba/tuUmUJB4litn5wHAjpqXCB3KV6WRekK mRaJn3pAYBpr2ZPa9zJJkdyOLo7nH++iVEsj/1c7eFZ+8S78MV54oBHtGTFKtF4u JJkLS7Zp95EE5QW5ThcKTRTPsZeQQL0RiAbZ7crJBqtV3YB5xSiGGjKBz+EfJSiw gSCpiUYMvdSsgA== X-ME-Sender: X-Sasl-enc: nuSGb5op2PqhMBCcepgIdDYHxJ4lBf/LEmFzQSJIVkrm 1496352277 Received: from [192.168.1.2] (75-172-126-41.tukw.qwest.net [75.172.126.41]) by mail.messagingengine.com (Postfix) with ESMTPA id 23D83241D3; Thu, 1 Jun 2017 17:24:37 -0400 (EDT) Subject: Re: Can the result sets produced in SQL procedures be left open for the use of the calling program? To: Gugu Rama , pgsql-sql@postgresql.org References: From: Adrian Klaver Message-ID: <4e782262-9ac5-b007-8a6c-6069588e5cfe@aklaver.com> Date: Thu, 1 Jun 2017 14:24:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 06/01/2017 02:15 PM, Gugu Rama wrote: > Hi, > > May i ask, if I write an hll program and make a call to an sql > procedure, will the result set which is produced in the sql procedure be > available for the calling program, after the sql prodecure ends? FYI, Postgres has User Defined Functions(UDF) not stored procedures: https://www.postgresql.org/message-id/D960CB61B694CF459DCFB4B0128514C26AB7AE%40exadv11.host.magwien.gv.at Though it does not matter for this question. The answer is yes you can return a result set that can be consumed by another application. I do it all the time using Python as the end consumer. For the builtin language plpgsql see here: https://www.postgresql.org/docs/9.6/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING > > Example: > > HLL program body (which undertakes frontend tasks, gets input from the user) > . > . > . > Call to an SQL procedure (all due backend stuff, which creates a result > set depending on the input from the user) > . > . > . > HLL program body (sends the data in the result set to the screen) > > > Thank you.. > > Gulsum -- Adrian Klaver adrian.klaver@aklaver.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql