Skip to main content

Cinchy System values

@cinchy_row_id

The @cinchy_row_id variable returns the cinchy ID of the last-inserted row.

@cinchy_row_id is not the recommended method for Cinchy v5.0+, and does not work in PostgeSQL deployments. Use the OUTPUT clause with INSERT, UPDATE, DELETE instead.

Syntax

select @cinchy_row_id

Example

The below example inserts a new row into the First Name and Last Name columns of the [People] table. It then return the Cinchy ID of that row.

INSERT INTO [Contacts].[People] ([First Name],[Last Name])
VALUES ('John','Smith')

select @cinchy_row_id

OUTPUT

The OUTPUT clause should be used to return the cinchy ID of the last-inserted row.

CREATE TABLE #TempCinchyId ([NewId] BIGINT)

INSERT INTO [Domain].[Table] ([Column1], [Column2])
OUTPUT INSERTED.[Cinchy Id] INTO #TempCinchyId ([NewId])
VALUES (@Column1, @Column2)

SELECT t.[NewId] FROM #TempCinchyId t