Skip to Main Content
  • Questions
  • Cursor returns no value when executed by an external systems

Breadcrumb

Question and Answer

Chris Saxon

Thanks for the question, Mthokozisi.

Asked: August 23, 2021 - 5:19 pm UTC

Last updated: August 24, 2021 - 3:45 pm UTC

Version: EBS R12.1.2

Viewed 1000+ times

You Asked

Hi Tom,

I have been trying to figure out what could be causing an explicit cursor to return no value when opened. This only happens when an external system executes the procedure, but when the same procedure is executed in SQL developer with the exact same parameters values, the cursor returns the expected value.

Code sample:

Declare
l_date date;
cursor cur_date is
select sysdate
from dual;

begin
open cur_date;
fetch cur_date into l_date;
close cur_date;
end;


Your help will be highly appreciated.

Thanks
Mtho

and Chris said...

So what is the external program and how do you know the cursor returns no value when you run the PL/SQL block in it?

In the example, nothing is returned to the client and there's no further processing of the output. So you'll get the same result if the query selects zero, one or more rows. Which in SQL Dev, plus, etc. is just:

PL/SQL procedure successfully completed.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, August 24, 2021 - 1:43 pm UTC

Hi,

The external is onBase and cursors are used to validate parameters.
To debug the issue I stores all the parameters in a table before the validation begins. I then wrote an anonymous block calling the same procedure using the parameters from the table without any formatting. Everything worked fine but when the onBase system is calling the same procedure the cursors return not value.

Code Sample:
Declare
l_date date;
l_cur_msg varchar(50);
cursor cur_date is
select sysdate
from dual;

begin
open cur_date;
fetch cur_date into l_date;

if cur_date%NOTFOUND THEN
l_cur_msg := 'NOTFOUND';
else
l_cur_msg := 'FOUND';
end if;
close cur_date;
DBMS_OUTPUT.PUT_LINE('is_found: ' ||l_cur_msg);
DBMS_OUTPUT.PUT_LINE(''return value: '||l_date);
end;
Chris Saxon
August 24, 2021 - 3:45 pm UTC

I don't really understand what you're doing here. In any case I'm unfamiliar with onBase - I suggest reaching out to their support or finding forums related to this product if you need help with it.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library