sp with multiple Ref Cursors

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
m_kramar
Posts: 1
Joined: Thu 07 Feb 2013 00:43

sp with multiple Ref Cursors

Post by m_kramar » Thu 07 Feb 2013 00:57

I'm trying to use LinqConnect to map stored proc that returns 2 refcursors.
I'm using data context designer to add mapping to the sp.

When I'm trying to add the following

Code: Select all

create or replace procedure LargeTest
(
       Result1 OUT SYS_REFCURSOR,
       Result2 OUT SYS_REFCURSOR,
)
AS
BEGIN
...
END;
... DataContext constructor crashes with out of range exception.

When I change it to

Code: Select all

create or replace procedure LargeTest
(
       Id INT,
       Result1 OUT SYS_REFCURSOR,
       Result2 OUT SYS_REFCURSOR,
)
AS
BEGIN
...
END;
... it crashes when mapping recordset to result objects, it cannot find columns by name.

When I change it to

Code: Select all

create or replace procedure LargeTest
(
       Name in Varchar2,
       Id in INT,
       DateFrom in Varchar2,       DateTo in Varchar2,

       Result1 OUT SYS_REFCURSOR,
       Result2 OUT SYS_REFCURSOR,
)
AS
BEGIN
...
END;
... it crashes with Oracle exception "wrong number or types of arguments".

Please help :)

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: sp with multiple Ref Cursors

Post by MariiaI » Thu 07 Feb 2013 14:32

Thank you for the report on this. We have reproduced the first and third issues. We will inform you when they are fixed.
As a workaround, you could try doing the following steps:
1) Open used template in the Model Explorer (to make the template available for editing, copy it to the model folder by right-clicking the template in Model Explorer and selecting 'Copy to Model Folder' from the shortcut menu); find the next lines

Code: Select all

if (method.MethodType == MethodType.MultipleResult) {
          int count = 1; 
          foreach (BaseClass type in (IList)method.ReturnType) {
#>
        [Devart.Data.Linq.Mapping.ResultType(typeof(<#= codeProvider.GetValidIdentifier(type.FullName) #>), <#= count++ #>)]
<#+
          }
        }
Change ' int count = 1;' to ' int count = 0;' in this code. Save changes and re-generate the code.
2) Re-create your stored procedures so that the OUT SYS_REFCURSOR parameters were the first ones, ie:

Code: Select all

create or replace procedure LargeTest
    (
           Result1 OUT SYS_REFCURSOR,
           Result2 OUT SYS_REFCURSOR,
           Name in Varchar2,
           Id in INT,
           DateFrom in Varchar2,  
           DateTo in Varchar2,         
    )
    AS
    BEGIN
    ...
    END;
As for the second issue, if the workaround described above, does not help to solve it, please send us a sample project with a SQL script for creating the procedure, so that we are able to reproduce it and investigate in more details.

Some useful information about using stored procedures with out cursor parameters in LinqConnect is available here: http://www.devart.com/linqconnect/docs/ ... eters.html

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: sp with multiple Ref Cursors

Post by MariiaI » Wed 20 Feb 2013 06:22

The bug related to the first issue you've reported (the "Index must be within the bounds of the List. Parameter name: index" exception) has been fixed. The fix will be included in the next build of LinqConnect. We will inform you when it is available for download.

Post Reply