RosettaCodeData/Task/Detect-division-by-zero/DuckDB/detect-division-by-zero.duckdb

9 lines
290 B
Plaintext

# WARNING: This definition is not intended to be useful!
create or replace function divide_or_error(x, y) as (
with xy as (select x/y as xy)
select if (xy IN ('-Infinity', 'Infinity') or xy IS NULL,
error(format('division by zero: {}/{}',x,y)),
xy)
from xy
);