-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprc_aux_assert_equal.sql
More file actions
30 lines (24 loc) · 1.34 KB
/
Copy pathprc_aux_assert_equal.sql
File metadata and controls
30 lines (24 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
create or alter exception AUX_ASSERT_EXCEPTION 'ASSERT';
set term ^ ;
create or alter procedure aux_assert_equal(
left_value varchar(1024) -- Left/first value to comparison
, right_value varchar(1024) -- Right/second value to comparison
, message_prefix varchar(1024) = '' -- Prefix for error message
)
as
declare error_message varchar(4096);
begin
-- author: atronah (look for me by this nickname on GitHub and GitLab)
-- source: https://github.com/atronah/firebird_utils
if (left_value is distinct from right_value
or char_length(left_value) is distinct from char_length(right_value))
then exception AUX_ASSERT_EXCEPTION coalesce(message_prefix, '')
|| 'Value `' || coalesce(left_value, 'null')
|| '` is not equal to value `'
|| coalesce(right_value, 'null') || '`';
end^
set term ; ^
comment on procedure aux_assert_equal is 'Procedure for equality test of two values and throwing exception if they don''t equal';
comment on parameter aux_assert_equal.left_value is 'Left/first value to comparison';
comment on parameter aux_assert_equal.right_value is 'Right/second value to comparison';
comment on parameter aux_assert_equal.message_prefix is 'Prefix for error message';