MSSQL: Unidac ExecSql, db trigger returning ID
Posted: Thu 11 Apr 2013 21:00
Hello!
We have a product that uses UniDac for MSSQL. We have triggers set up that return the ID of the last inserted row in the result dataset when an insert is performed (this is for compatibility with MS Entity Framework). When I call "ExecSql" or "Execute," on an insert query, I get the following error:
Is there any way to disable this check? I am using UniDac Professional (no source code).
Example trigger:
We have a product that uses UniDac for MSSQL. We have triggers set up that return the ID of the last inserted row in the result dataset when an insert is performed (this is for compatibility with MS Entity Framework). When I call "ExecSql" or "Execute," on an insert query, I get the following error:
Code: Select all
Query must return exactly one result set - use Execute.Example trigger:
Code: Select all
CREATE TRIGGER [TABLE]_BI ON [TABLE] INSTEAD OF INSERT as
BEGIN
declare @LOCATOR INT
SET @LOCATOR = (SELECT [KEYFIELD] FROM INSERTED)
IF @LOCATOR is null or @LOCATOR = 0 BEGIN
exec UNIQUE_ID [UNIQUEID], @LOCATOR OUTPUT
SELECT * INTO #Inserted FROM INSERTED
UPDATE #Inserted SET [KEYFIELD] = @LOCATOR
SET NOCOUNT ON;
INSERT INTO [TABLE] SELECT * FROM #Inserted
select [KEYFIELD] as "[KEYFIELD]" from #Inserted
END
ELSE
BEGIN
SET NOCOUNT ON;
INSERT INTO [TABLE] SELECT * FROM INSERTED
select [KEYFIELD] as "[KEYFIELD]" from INSERTED
END
END;