oracle / dotnet-db-samples

.NET code samples for Oracle database developers #OracleDotNet
http://otn.oracle.com/dotnet
MIT License
413 stars 191 forks source link

ORA-06550 when using InsertUsingStoredProcedure and others in EFCore 8. #366

Closed Bellgrad closed 6 months ago

Bellgrad commented 6 months ago

I recently had to use some functions and stored procedures in EFCore 8. We are currently on Oracle 19c.

I used what EFCore recommends since EFCore 7, for inserting, updating, and deleting based on stored procedures. But when I try to insert, I get the ORA-06550 error.

When using InsertUsingStoredProcedure like this :

builder.InsertUsingStoredProcedure(name: "{PACKAGE}.{FUNCTION}", schema: "{SCHEMA}", action => { [...] }

I got this query rendered :

 DECLARE

      v_RowCount INTEGER;
      v0_p_date_creation TIMESTAMP(7);

      BEGIN

      "{SCHEMA}"."{PACKAGE}.{FUNCTION}"(:p0, :p1, :p2, :p3, :p4);

      END;

EFCore is adding quotation marks. But this is not supposed to.

Since the examples nor documentations indicate nothing than using what EFCore 7 recommends, what is the issue here ?

alexkeh commented 6 months ago

I believe you're hitting a known limitation described in the README.

Database Scalar Function Mapping

Bellgrad commented 6 months ago

I believe you're hitting a known limitation described in the README.

Database Scalar Function Mapping

  • Database scalar function mapping does not provide a native way to use functions residing within PL/SQL packages. To work around this limitation, map the package and function to an Oracle synonym, then map the synonym to the EF Core function.

Hello,

This doesnt work. It does the same thing. It always add quotations mark. It seems that the name and scheme indicated in InsertUsingStoredProcedure always add quotations mark inside this query like any other query for selection.

I suppose it will be the same with a procedure in my package. I'll try with a procedure to check.

alexkeh commented 6 months ago

@Bellgrad Oracle EF Core puts quotation marks because Oracle DB is case insensitive without quotes. .NET is case sensitive. This is why we need to add quotes to the DB object names.

EF Core does not distinguish between package and schema names. MS has confirmed this. This is why the synonym workaround is recommended.