0001: ALTER procedure [dbo].[InsertUserDataHeader]
0002: @UserID uniqueidentifier,
0003: @ContentTypeName nvarchar(50),
0004: @ToGroup int,
0005: @ContentName nvarchar(250),
0006: @FileName nvarchar(300),
0007: @DataPostedType nvarchar(50),
0008: @Len int,
0009: @IsPorn bit = null,
0010: @IsNoComment bit = null,
0011: @Parts int,
0012: @OriginalWidth int
0013: as
0014: declare @NullableToGroup int
0015: declare @RecordNumber int
0016: if (@ToGroup = 0) select @NullableToGroup = NULL else select @NullableToGroup=@ToGroup
0017:
0018: Begin Tran
0019:
0020: BEGIN TRY
0021: -- эта проца вставляет только заголовок бинарника
0022: INSERT [UserData] ([ToUser],[ToContentType],[ToGroup],[Name],[FileName],[Len],[DataPostedType],[LoadDate],[IsPorn],[IsNoComment], Parts, OriginalWidth)
0023: select @UserID, ContentType.i, @NullableToGroup ,@ContentName,@FileName,@Len,@DataPostedType,GetDate(),@IsPorn,@IsNoComment,@Parts, @OriginalWidth
0024: from ContentType
0025: where ContentType.TypeName=@ContentTypeName
0026: IF @@ERROR <> 0 Begin
0027: Select NULL as RecordNumber, ERROR_MESSAGE() AS ErrorMessage
0028: rollback tran
0029: END
0030: select @RecordNumber=scope_Identity()
0031:
0032: Select @RecordNumber as RecordNumber,NULL AS ErrorMessage
0033: commit tran
0034: return 0
0035:
0036: END TRY
0037:
0038: BEGIN CATCH
0039: Select NULL as RecordNumber, ERROR_MESSAGE() AS ErrorMessage
0040: rollback tran
0041: END CATCH
0042: GO
0001: ALTER procedure [dbo].[InsertUserDataBinary]
0002: @ToUserData int,
0003: @Data varbinary(max),
0004: @Parts int
0005: as
0006: declare @NullableToGroup int
0007: declare @SectionNumber int
0008:
0009: Begin Tran
0010:
0011: BEGIN TRY
0012: -- эта проца вставляет только данные по готовому заголовку
0013: INSERT vOtpusk_Image.dbo.Bin(ToUserData,Part,Data) Values (@ToUserData,@Parts,@Data)
0014: IF @@ERROR <> 0 Begin
0015: Select NULL as SectionNumber, ERROR_MESSAGE() AS ErrorMessage
0016: rollback tran
0017: END
0018: select @SectionNumber=scope_Identity()
0019:
0020: Select @SectionNumber as SectionNumber, NULL AS ErrorMessage
0021: commit tran
0022: return 0
0023:
0024: END TRY
0025:
0026: BEGIN CATCH
0027: Select NULL as SectionNumber, ERROR_MESSAGE() AS ErrorMessage
0028: rollback tran
0029: END CATCH
0030: GO
Comments (
)
Link to this page:
//www.vb-net.com/asp2/34/9.htm
|