Skip to content

ORA-02012: missing USING keyword when performing UPSERT on Oracle #79

@j3t0n

Description

@j3t0n

Code example

await dbContext.ExecuteBulkInsertAsync(entities, onConflict: new OnConflictOptions
{
Match = e => new { e.Name },
Update = (inserted, excluded) => new TestCostType
{
CostType = inserted.CostType,
Amount = inserted.Amount,
CreatedAt = inserted.CreatedAt
}
});:

Details:

The Id column is generated by Oracle (identity).
I also tried using the Id column (generated by Oracle) in the Match expression, but the error persists.

The table is in a specific schema, e.g., GPC_DM.TEST_COST_TYPE.

Bulk insert without OnConflictOptions works fine.

Using OnConflictOptions triggers the ORA-02012 error.

Expected behavior:

UPSERT should generate a correct MERGE statement for Oracle without the missing USING keyword.

Environment:

EF Core 8

Image

at OracleInternal.ServiceObjects.OracleConnectionImpl.VerifyExecution(Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, SqlStatementType sqlStatementType, Int32 arrayBindCount, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
at OracleInternal.ServiceObjects.OracleCommandImpl.VerifyExecution(OracleConnectionImpl connectionImpl, Int32& cursorId, Boolean bThrowArrayBindRelatedErrors, OracleException& exceptionForArrayBindDML, Boolean& hasMoreRowsInDB, Boolean bFirstIterationDone)
at OracleInternal.ServiceObjects.OracleCommandImpl.d__122.MoveNext()
at System.Threading.Tasks.ValueTask1.get_Result() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult()
at Oracle.ManagedDataAccess.Client.OracleCommand.d__269.MoveNext()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult() at Oracle.ManagedDataAccess.Client.OracleCommand.<ExecuteNonQueryAsyncHelper>d__237.MoveNext() at PhenX.EntityFrameworkCore.BulkInsert.BulkInsertProviderBase2.d__16.MoveNext()
at PhenX.EntityFrameworkCore.BulkInsert.BulkInsertProviderBase2.<CopyFromTempTableAsync>d__132.MoveNext()
at PhenX.EntityFrameworkCore.BulkInsert.BulkInsertProviderBase2.<BulkInsert>d__81.MoveNext()
at PhenX.EntityFrameworkCore.BulkInsert.BulkInsertProviderBase2.<BulkInsert>d__81.MoveNext()
at PhenX.EntityFrameworkCore.BulkInsert.BulkInsertProviderBase2.<BulkInsert>d__81.MoveNext()
at PhenX.EntityFrameworkCore.BulkInsert.Extensions.PublicExtensions.d__272.MoveNext() at PhenX.EntityFrameworkCore.BulkInsert.Extensions.PublicExtensions.<ExecuteBulkInsertAsync>d__122.MoveNext()
at PhenX.EntityFrameworkCore.BulkInsert.Extensions.PublicExtensions.d__14`1.MoveNext()
at GPC.Infrastructure.Repository.TemplateRepository.d__2.MoveNext() in

It seems like the generated SQL for UPSERT does not include the proper USING clause required by Oracle.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions