go-gorm / go-gorm/sqlserver

the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.

Open
#94 1 comment 1 reaction 1 assignee Claimed by @jinzhu View on GitHub
Dominant language
Go
Stars
66
Forks
52
PR merge metrics
No merged PRs in 30d

Description

Having a table like the following, with triggers

```
CREATE TABLE [dbo].[test](
[id] [bigint] IDENTITY(1,1) NOT NULL,
[test] [varchar](50) NULL,
CONSTRAINT [PK_test] PRIMARY KEY CLUSTERED ( [id] ASC))
GO
CREATE TRIGGER [dbo].[triggert_test]
ON [dbo].[test]
AFTER INSERT,DELETE,UPDATE
AS
BEGIN
SET NOCOUNT ON;
END
```

When using the orm with the create statement, in sql server it returns the following error.

```
mssql: The target table 'test' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
[71.636ms] [rows:0] INSERT INTO "test" ("test") OUTPUT INSERTED."id" VALUES ('Prueba');

```

The error is due to the fact that if the table has triggers it must be used in the OUTPUT statement together with INTO

Example: INSERT INTO "test" ("test") OUTPUT INSERTED."id" into @test VALUES ('Test');

Must declare the table variable "@test"

Is it possible to fix this

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.