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:"
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • 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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • 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.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • 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;
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • 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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.