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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:23:22+00:00 2026-05-30T06:23:22+00:00

I’ve got an ORACLE package which receives few parameters and returns – with some

  • 0

I’ve got an ORACLE package which receives few parameters and returns – with some other (output) parameters – a unique value (number).
Here’s is the package code:

create or replace
PACKAGE BODY           "USP_SHIPMENTS" AS

    PROCEDURE  usp_GetNewShipmentNumber
    (
    pErrorCode OUT NUMBER,
    pMessage OUT VARCHAR2,      
    pCompanyCode IN CHAR,
    pNumber OUT VARCHAR2
    )

    IS

      BEGIN

    pErrorCode := 0;

       UPDATE 
        UTSASHN
       SET 
        UTSASHN.UTSHNCOR = UTSASHN.UTSHNCOR + 1
       WHERE 
        UTSASHN.UTSHCOSC = pCompanyCode AND UTSASHN.UTSHTIPO = 'S***'
    RETURNING 
        CONCAT(TRIM(UTSASHN.UTSHDESC) , TRIM(to_char(UTSASHN.UTSHNCOR, '000000'))) INTO pNumber;

    EXCEPTION
        WHEN OTHERS THEN 
              pErrorCode := SQLCODE;
              ROLLBACK;

    END usp_GetNewShipmentNumber;

END USP_SHIPMENTS;

I’ve been using this package for a long time using ODP.NET and everything has always worked properly.
Now I am developing a new App with nHibernate 3.1.0.4000.
So far I’ve been able to map all my entities and execute regular queries. Everything works fine.
I was trying to call this package but I keep on getting errors.

This is the mapping for the PROCEDURE:

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="BpSpedizioni" namespace="BpSpedizioni.Domain">
    <sql-query name="GetNewShipmentNumber">
        { call USP_SHIPMENTS.usp_GetNewShipmentNumber ( :pErrorCode, :pMessage, :pCompanyCode, :pNumber) }
    </sql-query>
</hibernate-mapping>

and this is the call:

Session.GetNamedQuery("GetNewShipmentNumber")
      .SetParameter("pErrorCode", "")
      .SetParameter("pMessage", "")
      .SetParameter<string>("pCompanyCode", "HBP00")
      .SetParameter("pNumber", 0)
      .UniqueResult();

I’ve tried with .UniqueResult() or .ExecuteUpdate() or .List() but I can only get exceptions:

could not execute query
[ USP_SHIPMENTS.usp_GetNewShipmentNumber ]
  Name:pErrorCode - Value:  Name:pMessage - Value:  Name:pCompanyCode - Value:HBP00  Name:pNumber - Value:0
[SQL: USP_SHIPMENTS.usp_GetNewShipmentNumber]

and this is the InnerException:

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'USP_GETNEWSHIPMENTNUMBER'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

I can’t figure out what I am doing wrong!
Is there anybody who can help me?

  • 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-30T06:23:23+00:00Added an answer on May 30, 2026 at 6:23 am

    I managed to make it work.
    It might not be the best solution but it works.

    This is my mapping for the ORACLE PROCEDURE:

    <?xml version="1.0" encoding="utf-8"?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyAssembly">
        <sql-query name="GetNewShipmentNumber">
            { call MY_PACKAGE.usp_GetNewShipmentNumber ( :pCompanyCode ) }
        </sql-query>
    </hibernate-mapping>
    

    and this the ORACLE PACKAGE:

    HEADER:

    create or replace
    PACKAGE           "MY_PACKAGE" AS
    
        TYPE ReferenceCursor IS REF CURSOR;
    
        PROCEDURE  usp_GetNewShipmentNumber
            (
            pCursor OUT ReferenceCursor,
            pCompanyCode IN CHAR
            );
    
    END MY_PACKAGE;
    

    BODY:

    create or replace
    PACKAGE BODY           "MY_PACKAGE" AS
    
    PROCEDURE  usp_GetNewShipmentNumber
        (
            pCursor OUT ReferenceCursor,
            pCompanyCode IN CHAR
        )
    
    IS
    
        err_code NUMBER := 0;
        err_msg VARCHAR2(200) := '';
        ShipmentNumber VARCHAR2(10);
    
      BEGIN
    
       UPDATE 
            UTSASHN
       SET 
            UTSASHN.UTSHNCOR = UTSASHN.UTSHNCOR + 1
       WHERE 
            UTSASHN.UTSHCOSC = pCompanyCode AND UTSASHN.UTSHTIPO = 'S***'
        RETURNING 
            CONCAT(TRIM(UTSASHN.UTSHDESC) , TRIM(to_char(UTSASHN.UTSHNCOR, '000000'))) INTO ShipmentNumber;
    
        OPEN pCursor FOR
              SELECT ShipmentNumber AS DeliveryNoteNumber, err_code AS ErrorCode, err_msg AS ErrorMessage FROM DUAL;
    
        EXCEPTION
            WHEN OTHERS THEN 
              err_code := SQLCODE;
              err_msg := substr(SQLERRM, 1, 200);
              ROLLBACK;
    
        OPEN pCursor FOR
              SELECT '' AS DeliveryNoteNumber, err_code AS ErrorCode, err_msg AS ErrorMessage FROM DUAL;
    
    END usp_GetNewShipmentNumber;
    
    END MY_PACKAGE;
    

    As you can see I got rid of the return parameters which, apparently, do not work with nHibernate.
    I am returning a REF CURSOR instead.

    A REF CURSOR must always be the first parameter in a package (documentation (17.2.2.1))

    For Oracle the following rules apply:

    A function must return a result set. The first parameter of a
    procedure must be an OUT that returns a result set. This is done by
    using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to
    define a REF CURSOR type, see Oracle literature.

    Since I want to return a unique result and I am managing a complex type I’ve created a class:

    public class NewDeliveryNoteNumber
    {
        public string DELIVERYNOTENUMBER { get; set; }
        public decimal ERRORCODE { get; set; }
        public string ERRORMESSAGE { get; set; }
    }
    

    which will be populated easily like this:

    using (var tx = Session.BeginTransaction())
        {
        var x = Session.GetNamedQuery("GetNewShipmentNumber")
            .SetParameter<string>("pCompanyCode", "ABC")
            .SetResultTransformer(Transformers.AliasToBean<NewDeliveryNoteNumber>())
            .UniqueResult<NewDeliveryNoteNumber>();
    
        tx.Commit();
        }
    

    If someone is interested I’ve tried to answer another question with some more infos.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
i got an object with contents of html markup in it, for example: string

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.