I have the follwing question:
I have to insert a new row into the table JOBS and then i need the JobId for selecting in another table:
DDL of JOBS
USE [IBOS2_UniDex]
GO
/****** Object: Table [dbo].[Jobs] Script Date: 02/03/2015 14:18:04 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Jobs](
[JobId] [uniqueidentifier] NOT NULL,
[Sender] [nvarchar](max) NULL,
[Recipient] [nvarchar](max) NULL,
CONSTRAINT [PK_dbo.Jobs] PRIMARY KEY CLUSTERED
(
[JobId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
/****** Object: Default [DF__Jobs__JobId__1A14E395] Script Date: 02/03/2015 14:18:04 ******/
ALTER TABLE [dbo].[Jobs] ADD DEFAULT (newsequentialid()) FOR [JobId]
GO
Jobs in my program:
EXEC SQL DECLARE
Jobs TABLE
( JobId uniqueidentifier(36)
NOT NULL
,Sender ntext(41823)
,Recipient ntext(41823)
) END- EXEC.
on inserting a new job i declare:
EXEC SQL
INSERT INTO Jobs
(JobId
,Sender
,Recipient
) VALUES
(NEWID()
,:Jobs- Sender:Jobs- Sender- NULL
,:Jobs- Recipient:Jobs- Recipient- NULL
)
END- EXEC
after this, how can i find out the JobId, beacause the insert statement does not give back the JobId.




