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 6222021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:14:21+00:00 2026-05-24T08:14:21+00:00

Question : Is it possible to return using OUT : Both : A variable

  • 0

Question : Is it possible to return using OUT :

Both : A variable & A cursor, from my code below ??


I saw a similar question for SqlDB but after a really long search found no solution for OracleDB.

In PLSQL :

CREATE OR REPLACE
PROCEDURE SPGETRESULTANDSETFLAG
(
 pFilter VARCHAR2,
 pMaxRowCount VARCHAR2,
 pTableID RAW,
 myFlag OUT NUMBER,
 myCursor OUT types.cursorType
)
AS
BEGIN
 Declare
  CountQuery VARCHAR(20000) := '';
  DataQuery VARCHAR(20000) := '';
  ResultingRows NUMBER := -1;
 Begin
  myFlag := -1;

  CountQuery := 'SELECT COUNT(*) FROM ' 
                || F_GET_TABLENAME_FROM_ID(PTABLEID => pTableID)
                || ' WHERE ' || pFilter;
  EXECUTE IMMEDIATE CountQuery INTO ResultingRows;


  --Get the Return Value
  if( pMaxRowCount > ResultingRows ) then myFlag := 1; end if;


  DataQuery := 'SELECT * FROM '
                || F_GET_TABLENAME_FROM_ID(PTABLEID => pTableID) 
                || ' WHERE ' || pFilter; 
  --Get the Return Cursor
  Open myCursor for DataQuery;

 End;
END SPGETRESULTANDSETFLAG;

In Code Behind..

Database db = DBSingleton.GetInstance();
using (DbCommand command = db.GetStoredProcCommand(spName))
{
    //The three Add In Parameters... & then the Add out Parameter as below
    db.AddOutParameter(command, "myFlag", System.Data.DbType.Int32, LocVariable );
    using ( IDataReader reader = db.ExecuteReader(command))
    {
         //Loop through cursor values & store them in code behind class-obj(s)
    }
}

I Thought this was not possible as how do I read both the value & the cursor, because..

if only flag param out then i would use db.ExecuteNonQuery(..)
& if only cursor out then i would use db.ExecuteReader(..)

  • 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-05-24T08:14:23+00:00Added an answer on May 24, 2026 at 8:14 am

    Thank you for the answers

    I was really desperate to get a working result & somehow came across a solution & after reading a bit found out why it worked :


    Oracle Stored Procedure as is with no change.


    Code Behind – Changed as follows :

    Database db = DBSingleton.GetInstance();
    using (DbCommand command = db.GetStoredProcCommand(spName))
    {
        //The three Add In Parameters... & then the Add out Parameter as below
        db.AddOutParameter(command, "myFlag", System.Data.DbType.Int32, LocVariable );
        using ( IDataReader reader = db.ExecuteReader(command))
        {
             //Loop through cursor values & store them in code behind class-obj(s)
             //The reader must be closed before trying to get the "OUT parameter"
             reader.Close();
    
             //Only after reader is closed will any parameter result be assigned
             //So now we can get the parameter value.
             //if reader was not closed then OUT parameter value will remain null
             //Getting the parameter must be done within this code block
             //I could not get it to work outside this code block
             <Type> result = (typecast)command.Parameters["OUT_parameter_name"];
        }
    }
    //I USED THIS APPROACH TO RETURN MULTIPLE PARAMETERS ALONG WITH THE CURSOR READ
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My question is simple; is it possible to over object-orient your code? How much
In the context of this question link text is possible from a Controller that
I'm trying to figure out a way to return results by using the group
Possible Duplicate: Why does “abcd”.StartsWith(“”) return true? Whilst debugging through some code I found
Question: Is it possible to construct a web page that has a script to
It's quite possible a question like this has been asked before, but I can't
Question So I've recently came up with some new possible projects that would have
This question is directly related to my previous question ASP.NET AJAX Is it possible
Here is my question, Would it be possible, knowing that classic asp support server-side
This question is about App domains and Sessions. Is it possible to have IIS

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.