public inbox for [email protected]  
help / color / mirror / Atom feed
From: Jean-Marc Voillequin (MA) <[email protected]>
To: David Rowley <[email protected]>
Cc: Pavel Stehule <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: no_data_found oracle vs pg
Date: Mon, 18 Sep 2023 14:05:24 +0000
Message-ID: <MN2PR20MB2735F1267E36D5C5A4E57BA8BEFBA@MN2PR20MB2735.namprd20.prod.outlook.com> (raw)
In-Reply-To: <CAApHDvrhBh9PwphEUH973mtKjqT5MBN3tPB5sJmKj8G7ZtjWVA@mail.gmail.com>
References: <MN2PR20MB273509335B549DEB90AB5724BEF5A@MN2PR20MB2735.namprd20.prod.outlook.com>
	<CAFj8pRAfJy7du1O5fkCbNUPJticxrQpomu7mcPYs2vJNfEKkJw@mail.gmail.com>
	<MN2PR20MB27353A509944FDE44CBF5E5DBEFBA@MN2PR20MB2735.namprd20.prod.outlook.com>
	<CAApHDvrhBh9PwphEUH973mtKjqT5MBN3tPB5sJmKj8G7ZtjWVA@mail.gmail.com>

Thanks David,
It’s a very interesting idea.

From: David Rowley <[email protected]>
Sent: Monday, September 18, 2023 3:14 PM
To: Jean-Marc Voillequin (MA) <[email protected]>
Cc: Pavel Stehule <[email protected]>; [email protected]
Subject: Re: no_data_found oracle vs pg

On Mon, 18 Sept 2023 at 18: 49, Jean-Marc Voillequin (MA) <Jean-Marc. Voillequin@ moodys. com> wrote: > I know I can test the ROWCOUNT or the FOUND indicator, but it’s not what I want. > > I want a NO_DATA_FOUND exception to be raised
ZjQcmQRYFpfptBannerStart
This email originated from outside of Moody's
Do not click links or open attachments unless you recognize the sender and know the content is safe.
ZjQcmQRYFpfptBannerEnd

On Mon, 18 Sept 2023 at 18:49, Jean-Marc Voillequin (MA)

<[email protected]<mailto:[email protected]>> wrote:

> I know I can test the ROWCOUNT or the FOUND indicator, but it’s not what I want.

>

> I want a NO_DATA_FOUND exception to be raised when the function is called from a PL/pgSQL block, and I want the function to return a NULL value when called from SQL.



It would mean having to include logic in each function, but perhaps

GET DIAGNOSTIC PG_CONTEXT could be of some use.



You could adapt the following to call the STRICT or non-STRICT version

accordingly.



create or replace function myfunc() returns int as $$

declare ctx text;

begin

GET DIAGNOSTICS ctx = PG_CONTEXT;

if split_part(ctx, E'\n', 2) = '' then

raise notice 'top level';

else

raise notice 'nested';

end if;

return 1;

end;

$$ language plpgsql;



create or replace function callerfunc() returns int as $$

begin

return myfunc();

end;

$$ language plpgsql;





select myfunc();

select callerfunc();



David

----------------------------------------------------------------------
Moody's monitors email communications through its networks for regulatory compliance purposes and to protect its customers, employees and business and where allowed to do so by applicable law. The information contained in this e-mail message, and any attachment thereto, is confidential and may not be disclosed without our express permission. If you are not the intended recipient or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution or copying of this message, or any attachment thereto, in whole or in part, is strictly prohibited. If you have received this message in error, please immediately notify us by telephone, fax or e-mail and delete the message and all of its attachments. Every effort is made to keep our network free from viruses. You should, however, review this e-mail message, as well as any attachment thereto, for viruses. We take no responsibility and have no liability for any computer virus which may be transferred via this e-mail message.


view thread (6+ messages)

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: RE: no_data_found oracle vs pg
  In-Reply-To: <MN2PR20MB2735F1267E36D5C5A4E57BA8BEFBA@MN2PR20MB2735.namprd20.prod.outlook.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox