У меня есть проблема с этим кодом:Ошибка вставки в базу данных в хранимых процедурах
ALTER PROCEDURE [arch].[spInsertToDocumentFileCategoryRelation]
@DocumentNumber nvarchar(50)
,@DocumentDate date
,@IsDocumentDelete bit
,@Address nvarchar(max)
,@DocumentLevelTypeId int
,@DocumentId2 bigint
,@DocumentRelationTypeId tinyint
,@CategoryId bigint
,@FileId bigint
,@FileAssignCategoryId bigint OUTPUT
,@DocumentRelationId bigint OUTPUT
,@FileOfDocumentId bigint OUTPUT
,@DocumentId bigint OUTPUT
AS
BEGIN
INSERT INTO [arch].[Document]
(
[DocumentNumber]
,[DocumentDate]
,[DateOfDocumentCreate]
,[IsDocumentDelete]
,[Address]
,[DocumentLevelTypeId]
)
VALUES
(
@DocumentNumber
,@DocumentDate
,'2015-5-12'
,@IsDocumentDelete
,@Address
,@DocumentLevelTypeId
)
Set @DocumentId = SCOPE_IDENTITY();
INSERT INTO [arch].[FileOfDocument]
(
[DocumentId]
,[FileId]
)
VALUES
(
@DocumentId
,@FileId
)
Set @FileOFDocumentId = SCOPE_IDENTITY();
INSERT INTO [arch].[DocumentRelation]
(
[DocumentRelationTypeId]
,[DocumentId1]
,[DocumentId2]
)
VALUES
(
@DocumentRelationTypeId
,@DocumentId
,@DocumentId2
)
Set @DocumentRelationId = SCOPE_IDENTITY();
INSERT INTO [arch].[FileAssignCategory]
(
[CategoryId]
,[FileId]
)
VALUES
(
@CategoryId
,@FileId
)
Set @FileAssignCategoryId = SCOPE_IDENTITY();
END
этот код Выполнить правильно, но когда я хочу, чтобы проверить эту хранимую процедуру с некоторыми входными значениями, отчеты SQL Server некоторых ошибками:
Msg 515, Level 16, State 2, Procedure
spInsertToDocumentFileCategoryRelation, Line 27
Cannot insert the value NULL into column 'DocumentTypeId', table
'ffisherDB.arch.Document'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Msg 515, Level 16, State 2, Procedure
spInsertToDocumentFileCategoryRelation, Line 48
Cannot insert the value NULL into column 'DocumentId', table
'ffisherDB.arch.FileOfDocument'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Msg 515, Level 16, State 2, Procedure
spInsertToDocumentFileCategoryRelation, Line 61
Cannot insert the value NULL into column 'DocumentId1', table
'ffisherDB.arch.DocumentRelation'; column does not allow nulls. INSERT
fails.
The statement has been terminated.
(1 row(s) affected)
(1 row(s) affected)
(1 row(s) affected)
У меня есть четыре ключа, которые установлены с помощью SCOPE_IDENTITY(). первый из них настроен точно, но остальные терпят неудачу и выше отчета об ошибках.
, пожалуйста, помогите мне.
'Невозможно вставить значение NULL в столбец 'DocumentTypeId', таблицу 'ffisherDB.arch.Document'; столбец не допускает ошибок. «Говорит все это. –