Insert into a "stored procedure" table

Hello,

Using the schema modeler I’ve mapped a stored procedure (GetEventsHistory) into a table (dbo_EventsHistory) and then I would like to write:


_Module.LinqDataAdapter.GetTable<dbo_EventsHistory>().InsertRow(data);
_Module.LinqDataAdapter.ApplyChanges();

but the following error occurs:
RemObjects.DataAbstract.DAUpdatesFailedException: 'One or more updates failed to apply on the server.

Caused by this SQL Server statement executed by DA:

declare @p1 int
set @p1=NULL
exec sp_prepexec @p1 output,N'@EventId bigint,@Text nvarchar(500),@Status nvarchar(50),@EventTimeOn datetime,@EventTimeOff datetime,@Sender nvarchar(500),@Priority int',N'INSERT INTO **[]** (
  [EventId],
  [Text],
  [Status],
  [EventTimeOn],
  [EventTimeOff],
  [Sender],
  [Priority])
VALUES (
  @EventId,
  @Text,
  @Status,
  @EventTimeOn,
  @EventTimeOff,
  @Sender,
  @Priority)',@EventId=0,@Text=NULL,@Status=N'ManualShut',@EventTimeOn='2018-07-02 14:52:59.893',@EventTimeOff='2018-07-02 14:53:06.370',@Sender=NULL,@Priority=NULL
select @p1

It seems that the table name is empty but DA should know the entity name (from the same metadata you retrieve to get SP’s infos). Where’s the catch?

Thank you,
Matteo

Thanks, logged as bugs://80477

Hello

This clearly needs a better exception message.

Not exactly. DA should know the stored procedure name. But it is not the name of the entity that should be used to insert data into.

For a data table based on a StoredProcedure statement there are 2 ways to perform data updates:

  1. Either set the Target Table property of the table Statement. In this case data will be retrieved via Stored Procedure whilde updates will go directly into the specified Target Table
  2. Or use the Insert / Update / Delete commands (the ones that can be defined when you select the table in the Schema Modeler)

Regards

bugs://80477 got closed with status fixed.