System SQL functions for diagnostics

as_print allows you to check the values when executing a stored procedure. Its output is on the /start page in the admin control panel. Creates an entry in as_trace with the code print

exec as_print @str='132' 

Do not leave print on a permanent basis-otherwise it will complicate the analysis of the output of as_print in the future. We checked some values and removed them from the code. 

as_warning fixes possible problem situations. This is not a full-fledged error, but it can have negative effects (for example, too many files are linked to the order). Creates an entry in as_trace with the warning code.

exec [as_warning] @str =''[, @place = '', @itemID=0]

as_error - fixes the error. If there is an SQL exception, the data on the exception will also be recorded. Creates an entry in as_trace with the exception code.

exec as_error @str='132' 

Stored procedure texts

as_print: 

CREATE OR ALTER PROCEDURE [dbo].[as_print]
(
    @str as varchar(max)
)
AS
BEGIN
	insert into as_trace (code, text, created) values ('print', left(@str, 2048), getdate())
	print @str
END

as_warning: 

CREATE or ALTER PROCEDURE [dbo].[as_warning]
(
    @str as varchar(max),
	@place as nvarchar(max) = '',
	@itemID int = 0
)
AS
BEGIN
	insert into as_trace (code, header, text, itemID,  created) values ('warning', @place, left(@str, 2048), @itemID, getdate())
	print @str
END

as_error:

CREATE OR ALTER procedure [dbo].[as_error]
@str nvarchar(max)
as
begin
	declare @s nvarchar(max) = isnull(@str , '') + ' '
	declare @errorMsg nvarchar(max) = ERROR_MESSAGE()
	if(isnull(@errorMsg, '')<>'')begin
		set @s += 'Msg: ' + @errorMsg +
			', Proc: '+ isnull(ERROR_PROCEDURE() , 'n/a') +
			', Line: '+ isnull(try_cast(ERROR_LINE() as nvarchar) , 'n/a') +
			', ErrorNumber: '+ isnull(try_cast(ERROR_NUMBER() as nvarchar) , 'n/a')
	end
	print @s

declare @t table(id int)

insert into @t
exec as_trace_warn
	@code ='exception',
	@header = @s,
	@itemID =0,
	@text ='',
	@username = ''

Falcon Space is a functional web development platform on a narrow stack MS SQL/Bootstrap. Falcon Space Gettting started
{sp-shortDemostandLinks}