Skip to content

Instantly share code, notes, and snippets.

@Jonathan-49
Last active February 3, 2025 07:37
Show Gist options
  • Save Jonathan-49/831c4ee26322af48e2bc06d857b15ca0 to your computer and use it in GitHub Desktop.
Save Jonathan-49/831c4ee26322af48e2bc06d857b15ca0 to your computer and use it in GitHub Desktop.
IBM i Db2 Check for digits
-- Will return 0 if the string contains only digits
-- or the number of characters found.
-- OS: IBM i Db2
Create or replace Function isNumeric (
V_INPUT VarChar(1000))
Returns INT
Language SQL
Deterministic
Reads SQL Data
Called on NULL Input
Disallow Parallel
Return
length(replace(trim(translate(V_INPUT, ' ',
'1234567890' )), ' ', ''));
End;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment