Skip to Main Content

Oracle Developer Tools for Visual Studio

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

.Net stored procedure returning System.InvalidOperationException: 'Sequence contains no elements

User_S5YKKApr 25 2022

 I am trying to call an Oracle stored procedure and getting "Sequence contains no elements".
I changed it to firstordefault as many posts say but still get the same error. I changed the stored procedure to be as simple as possible just to see if I can get any results but I am unable to.

CREATE OR REPLACE 
 PROCEDURE get_registration
   (returnRecords Out SYS_REFCURSOR)
   IS

BEGIN
     open returnRecords for
     Select Admin_Comments
     from registration
     order by ID desc;
 END; -- Procedure
 /



using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Oracle.ManagedDataAccess.Client;
using Oracle.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using SDD_Training.DataAccess.Repository.IRepository;
using SDD_Training.Models;

 public int GetorCreateRegistration(Registration id)
    {
        if (id != null)
        {
         OracleParameter pout = new OracleParameter("returnRecords", 
         OracleDbType.RefCursor, ParameterDirection.Output);
         object[] parameters = new object[] { pout };

         var results = _db.RESULTS.FromSqlRaw("BEGIN get_registration(:returnRecords); END;", new object[] { parameters }).FirstOrDefault();
Comments
Post Details
Added on Apr 25 2022
0 comments
478 views