Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ef798f8

Browse files
authored
USE EXAMPLES
1 parent ba3fbf3 commit ef798f8

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

‎functions/raise_exception.sql‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ begin
3131
constraint = coalesce("constraint", ''),
3232
table = coalesce("table", ''),
3333
schema = coalesce("schema", ''),
34-
datatype = pg_typeof(value);
34+
datatype = pg_typeof(value)::text;
3535
return null::bool;
3636
end;
3737
$$;
3838

39-
--TEST
39+
--TEST FUNCTION
4040
do $$
4141
DECLARE
4242
i int not null default 0;
@@ -92,15 +92,25 @@ do $$
9292
END;
9393
$$;
9494

95-
/*
96-
--explain
95+
------------------------------------------------------------------------------------------------------------------------
96+
--USE EXAMPLE 1
97+
select case finger
98+
when 1 then 'one'
99+
when 2 then 'two'
100+
when 3 then 'three'
101+
when 4 then 'four'
102+
when 5 then 'five'
103+
else raise_exception(finger)::text
104+
end
105+
from unnest(array[1, 2, 3, 4, 5]::int[]) as hand(finger);
106+
107+
--USE EXAMPLE 2
97108
select i
98-
from generate_series(1, 3000000) as x(i)
109+
from generate_series(1, 300) as x(i)
99110
where case when clock_timestamp() - statement_timestamp() < '1s'
100111
then true
101112
else raise_exception(i)
102113
end
103114
order by i;
104-
*/
105115

106-
--https://stackoverflow.com/questions/24882630/equivalent-or-alternative-method-for-raise-exception-statement-for-function-in-l
116+
--TODO https://stackoverflow.com/questions/24882630/equivalent-or-alternative-method-for-raise-exception-statement-for-function-in-l

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /