Starts in:
1 DAY
17 HRS
5 MIN
7 SEC
Starts in:
1 D
17 H
5 M
7 S
Open Closed

Work with Oracle Store Procedure #2617


User avatar
0
piseth created
  • ABP Framework version: v5
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

5 Answer(s)
  • User Avatar
    0
    piseth created

    Hello,

    My Abp is MVC Razor with Oracle. I'd like to know how to work with Oracle Procedure?

    The following sample is working with Store Procedure, but it is for SQL Server. https://github.com/abpframework/abp-samples/tree/master/StoredProcedureDemo

    How can i make my project work with Oracle procedure?

    Thanks in advance

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I think you just need to change the syntax of the SQL server to the oracle, the principle is the same.

    https://github.com/abpframework/abp-samples/blob/master/StoredProcedureDemo/src/StoredProcedureDemo.EntityFrameworkCore/EntityFrameworkCore/Users/AppUserRepository.cs#L27-L40

  • User Avatar
    0
    piseth created

    hi

    I think you just need to change the syntax of the SQL server to the oracle, the principle is the same.

    https://github.com/abpframework/abp-samples/blob/master/StoredProcedureDemo/src/StoredProcedureDemo.EntityFrameworkCore/EntityFrameworkCore/Users/AppUserRepository.cs#L27-L40

    Thank for your reply. please share me a sample function to do that. I don't know that is why i requested you. Honestly, I will copy and paste into my application.

  • User Avatar
    0
    piseth created

    Is it correct?

    public async Task<List<Student>> GetStudentAsync(CancellationToken cancellationToken = default)
    {
             var name = new OracleParameter("Name", OracleDbType.Varchar2, ParameterDirection.Output);
             var address = new OracleParameter("Address", OracleDbType.Varchar2, ParameterDirection.Output);
            
           using (var command = CreateCommand("BEGIN GetStudent(:Name, :Address,);END;", CommandType.Text, new OracleParameter[] { name, address }))
                {
                    return ((List<Student>)await command.ExecuteScalarAsync(cancellationToken));
                }
     }
    
    private DbCommand CreateCommand(string commandText, CommandType commandType, params OracleParameter[] parameters)
    {
        var command = DbContext.Database.GetDbConnection().CreateCommand();
    
        command.CommandText = commandText;
        command.CommandType = commandType;
        command.Transaction = DbContext.Database.CurrentTransaction?.GetDbTransaction();
    
        foreach (var parameter in parameters)
        {
            command.Parameters.Add(parameter);
        }
    
        return command;
    }
    
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I'm not familiar with Oracle, you can try your solution.

    https://www.google.com/search?q=oracle+entity+framework+core+execute+stored+procedure&oq=ORACLE+EF+CORE+EXEC+&aqs=chrome.1.69i57j0i22i30.5767j0j7&sourceid=chrome&ie=UTF-8

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06