Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7882779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:21:57+00:00 2026-06-03T04:21:57+00:00

I have a stored procedure with two input, two output params and 5 sys_refcursors.

  • 0

I have a stored procedure with two input, two output params and 5 sys_refcursors.
I had a succesful IF/ELSE where I opened these cursors by calling different stored procs but now need a third option which is another stored proc call. The third option is virtually identical to the second with one difference.

I was pretty sure I got the nested if statement correct but I keep getting ora-24338 Statement handle not executed when it tries to get the cursors from the this new call.

The problem stored procedure call is the middle one.

create or replace Procedure  procedure_name (
    OutVar out varachar2,
    Outvar2  out number,
    inParam1 date,
    REf-Cur1 in out sys_refcursor,
    REf-Cur2 in out sys_refcursor,
    REf-Cur3 in out sys_refcursor,
    REf-Cur4 in out sys_refcursor,
    REf-Cur5 in out sys_refcursor
) 
is
  tIsBindVar1 varchar2(100);
  tIsBindVar2 varchar2(100);
  tOutVar1    varchar2(100);
  TOutVar2    varchar2(100);
Begin
  Select Max(T.Var1) 
    into tIsBindVar1
    From table1 
   where T.aField = inParam1;

Select Function_Name (inParam1) 
  into tIsBindVar2 
  from Dual;

IF tIsBindVar1 is NOT NULL 
THEN
  Select P.Field_A P.Field_B 
    INTO tOutVar1, tOutVar2
    FROM table1 
  WHERE P.Field_A = inParam1;

  Stored_Proc_One (tInParam => tOutVar1, 
                   inParam1 => inParam1, 
                   5 cursors => 5 cursors);
ELSE 
  IF tIsBindVar2 = 'Y' 
  THEN
    Stored_Proc_Two (inParam1 => inParam1, 
                     5 cursors => 5 cursors);
  ELSE 
    Stored_Proc_Three ();
    Stored_Proc_Two ( inParam1 => inParam1, 5 cursors => 5 cursors);
  END IF;
END IF;

SELECT tOutVar1, tOutVar2 
  INTO OutVar1, OutVar2 
  FROM DUAL;

Some quick extra notes.

Stored_procs one and two are straight up data grabs, nothing fancy, stored proc 3 generates some data based on some input params (not listed) and stored proc 2 is called to collect.

I can change these stored proc calls around and I always wind up with the same error from the middle one. That includes changing the conditions in any order.

I tried to simplify the code as I’m not looking for anyone to do the work for me but to try and get understanding what the problem is.

Hopefully I did not leave anything important out but I think the issue is something with how I’m doing the nested if. I certainly don;t think the issue is in the the stored procs themselves as I say they work when I change the order.

So if long winded and very hard to read code. Going to try and find where they keep the editing info and clean it up.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:21:59+00:00Added an answer on June 3, 2026 at 4:21 am

    What are the values of tIsBindVar1 and tIsBindVar2?

    Do you really want the IF statement structured the way I formatted it? Or do you really want

    IF  tIsBindVar1 is NOT NULL 
    THEN
      <<do something>>
    ELSIF tIsBindVar2 = 'Y' 
    THEN
      <<do something else>>
    ELSE 
      <<do one more thing>>
    END IF;
    

    If you want to ensure that at least one path is followed in all cases, you’d want an IF ELSIF ELSE.

    Incidentally, there is no need for all those SELECT FROM dual statements. You can simply assign variables in PL/SQL

    tIsBindVar2 := Function_Name (inParam1);
    

    and

    tOutVar1 := OutVar1;
    tOutVar2 := OutVar2;
    

    are more conventional.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm calling a mysql stored procedure with two input parameters. This is the code
I have two stored procedures I wish to use in my stored procedure, but
I have a stored procedure that takes no parameters, and it returns two fields.
I have two PL/SQL Stored procedure each handling its own Transaction (Begin/Commit and Rollback
I have a stored procedure that needs to return something from one of two
We have a stored procedure in which there are two parts. In part 1,
I have a stored procedure that selects from a table, two of the fields
I have a stored procedure which calculates the distance between two coordinate pairs as
I have a stored procedure in my database that calculates the distance between two
Using SQL Server 2008, I have two stored procedures - create procedure [dbo].[SH_Export_data] (@unit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.