SQL Insert Statement returning Identity of record using OUTPUT statement

SQL Insert Statement returning Identity of record using OUTPUT statement

  

Hi,

I've searched the forums already, but haven't found an answer.

I'm creating a SQL which inserts into a table (dynamically, via input parameter @EntityName). 

I would like to return the Id of the record inserted. I do this via the line:

OUTPUT INSERTED.Id INTO @InsertTableVar

PROBLEM: How can I escape the @InsertTableVar as being part of the SQL statement? OutSystems thinks that @InsertTableVar is an input parameter... but it is really just part of the SQL text.

SyntaxEditor Code Snippet

DECLARE @InsertTableVar TABLE(RecordId INT);

INSERT {@EntityName} 
(
    {@EntityName}.[Name], 
    {@EntityName}.[Description], 
    {@EntityName}.[Order], 
    {@EntityName}.[Is_Active]
) 
OUTPUT INSERTED.Id INTO @InsertTableVar
VALUES (@Name, @Description, @Order, @Is_Active);

SELECT @InsertTableVar.RecordId FROM @InsertTableVar;

Besides the why on earth would you want to do something like this in outsystems.

Will expandinline set on true not work and giving @insetwhatver as inout?