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

  • Home
  • SEARCH
  • 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 9131873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:12:56+00:00 2026-06-17T08:12:56+00:00

I am trying to use Oracle.DataAccess to connect to the Oracle database from Visual

  • 0

I am trying to use Oracle.DataAccess to connect to the Oracle database from Visual Studio 2012 (c#) and run FUNCTION which is part of a PACKAGE. below is the SQL:

FUNCTION TEST (test_name in varchar2,
   test_year in number,
   test_outmessage out varchar2)
RETURN NUMBER IS
   test_exists     VARCHAR2(1) := 'N';
BEGIN
   BEGIN
      SELECT 'Y' INTO test_exists
        FROM Test_Table
       WHERE table_name = test_name
         AND table_year = test_year;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         test_exists := 'N';
      WHEN OTHERS THEN
         test_outmessage := 'error'
         DBMS_OUTPUT.put_line (test_outmessage);
         RETURN -1;
   END;

   IF test_exists = 'Y' THEN
      RETURN 1;
   ELSE
      RETURN 0;
   END IF;

END TEST;

I have written c# code to execute this function from my app:

 using (OracleConnection connection = new OracleConnection("Data Source=Database; User ID=user; Password=pass"))
{
  OracleCommand command = connection.CreateCommand();
  command.CommandType = System.Data.CommandType.StoredProcedure;
  command.CommandText = "USER.PACKAGE.TEST";


   OracleParameter test_name = new OracleParameter();
   test_name.ParameterName = "test_name";
   test_name.OracleDbType = OracleDbType.NVarchar2;
   test_name.Direction = System.Data.ParameterDirection.Input;
   test_name.Value = "myname";
   command.Parameters.Add(test_name);

   OracleParameter test_year = new OracleParameter();
   test_year.ParameterName = "test_year";
   test_year.OracleDbType = OracleDbType.Decimal;
   test_year.Direction = System.Data.ParameterDirection.Input;
   test_year.Value = 2004;
   command.Parameters.Add(test_year);

   OracleParameter test_outmessage = new OracleParameter();
   test_outmessage.ParameterName = "test_outmessage ";
   test_outmessage.OracleDbType = OracleDbType.NVarchar2;
   test_outmessage.Direction = System.Data.ParameterDirection.Output;
   command.Parameters.Add(test_outmessage);

   OracleParameter result = new OracleParameter();
   result.ParameterName = "ReturnValue";
   result.OracleDbType = OracleDbType.Decimal;
   result.Direction = System.Data.ParameterDirection.ReturnValue;
   command.Parameters.Add(result);
   try
   {
         connection.Open();

         command.ExecuteNonQuery();
         string r = result.Value.ToString();
         string r1 = test_outmessage.Value.ToString();
   }
   catch (Exception)
   {

   }
   finally
   {
          connection.Close();

    }
 }

There is no exception when I run this code, however, the return value (Both r and r1) is null. As in the function, I should expect -1, 1 or 0 for string r I guess.

  • 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-17T08:12:56+00:00Added an answer on June 17, 2026 at 8:12 am

    Found the answer. Oracle cares about the sequence in which the parameter is added, Return Value should be the first parameters added to the OracleCommand.

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

Sidebar

Related Questions

I am trying to connect to oracle database from c++ using OCCI, I am
I'm trying to use cx_Oracle to connect to an Oracle instance and execute some
Im trying to use Enterprise Architect to model Oracle database. Everything is going fine,
I'm trying to use oracle 10g and ebeans for the computer database sample application
I'm trying to use an Oracle database with ado.net, and it is proving a
I am trying to use Ant to initialize my Oracle database by using Ant.
Oracle version : 10g I'm trying to use the MIN function to find the
I'm trying to use Oracle LogMiner ( DBMS_LOGMNR package) for implementation of audit trails
I have been trying to use BLToolkit to activate an Oracle stored procedure which
I'm trying to access my Oracle XE database using Visual C# Express and entity

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.