我想知道如果有 0 个结果,我必须怎么做才能在以下存储过程中引发异常,以便它可以选择 NULL 行?这是针对 MSSQL 的,非常感谢。
...
BEGIN TRY
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT
NoteId,
Url,
Subject,
Content,
ExpiresAt,
RemindAt
FROM dbo.browsingnotes_Notes
WHERE UserId = @UserId
AND Hash = @Hash
END TRY
BEGIN CATCH
SELECT
NULL AS 'NoteId',
NULL AS 'Url',
NULL AS 'Subject',
NULL AS 'Content',
NULL AS 'ExpiresAt',
NULL AS 'RemindAt'
END CATCH