Is there an inbuilt DB2 function or any query to check if the character i have is a number? (I cannot use user defined functions)
The ISNUMERIC() function tests whether an expression is numeric. This function returns 1 if the expression is numeric, otherwise it returns 0.
Numeric in Db2 database are columns with the following data types: smallint, integer/int, bigint, decimal/numeric, real, double, decfloat.
The VARCHAR function returns a varying-length character string representation of one of the following values: An integer number if the first argument is a SMALLINT, INTEGER, or BIGINT. A decimal number if the first argument is a decimal number.
The Db2 INSTR() function finds a substring in a string and returns the position of the nth occurrence of the substring.
Doc Link
CASE
WHEN LENGTH(RTRIM(TRANSLATE(test_str, '*', ' 0123456789'))) = 0
THEN 'All digits'
ELSE 'No'
END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With