Location>code7788 >text

Sqlsugar Calls Oracle Stored Procedures

Popularity:283 ℃/2024-11-08 10:51:23

Some time ago in the relocation project, encountered a problem, is to use sqlsugar call oracle stored procedure call can not;

I was stuck all day, but now I have time to share the record of this problem.

Go to nuget and install the sqlsugar package first:

Install another oracle driver:

Add the Json package:

Go ahead and create the connection again.

Create another stored procedure for testing

create or replace procedure pr_test(i_name   in varchar2,
                                    i_age    in varchar2,
                                    o_result out sys_refcursor) as

begin

  open o_result for
    select * from dual;

end pr_test;

Create a class to accept the data returned by the procedure

    public class People
    {
        public string Dummy { get; set; }
    }

Taking that sql inside the stored procedure alone and executing it gives the following result:

dual this table is oracle provides a table, inside a X, you can generally use this to test the database connection is not normal.

The call is made as follows:

The one in there.cursor (computing) (*)must be a null character, I've tried object, null before, I just never thought it would be a null character.

I also didn't realize at the time that a null character stuck me for an afternoon, a pit I shouldn't have to step in again.