How to resolve the algorithm Determine if a string is numeric step by step in the SQL PL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Determine if a string is numeric step by step in the SQL PL programming language
Table of Contents
Problem Statement
Create a boolean function which takes in a string and tells whether it is a numeric string (floating point and negative numbers included) in the syntax the language uses for numeric literals or numbers converted from strings.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Determine if a string is numeric step by step in the SQL PL programming language
Source code in the sql programming language
--#SET TERMINATOR @
CREATE OR REPLACE FUNCTION IS_NUMERIC (
IN STRING VARCHAR(10)
) RETURNS SMALLINT
-- ) RETURNS BOOLEAN
BEGIN
DECLARE RET SMALLINT;
-- DECLARE RET BOOLEAN;
DECLARE TMP INTEGER;
DECLARE CONTINUE HANDLER FOR SQLSTATE '22018'
SET RET = 1;
-- SET RET = FALSE;
SET RET = 0;
--SET RET = TRUE;
SET TMP = INTEGER(STRING);
RETURN RET;
END @
VALUES IS_NUMERIC('5')@
VALUES IS_NUMERIC('0')@
VALUES IS_NUMERIC('-1')@
VALUES IS_NUMERIC('A')@
VALUES IS_NUMERIC('-')@
VALUES IS_NUMERIC('z')@
VALUES IS_NUMERIC('')@
VALUES IS_NUMERIC(' ')@
You may also check:How to resolve the algorithm Flipping bits game step by step in the C++ programming language
You may also check:How to resolve the algorithm SEDOLs step by step in the REXX programming language
You may also check:How to resolve the algorithm Zhang-Suen thinning algorithm step by step in the Fortran programming language
You may also check:How to resolve the algorithm Address of a variable step by step in the J programming language
You may also check:How to resolve the algorithm CUSIP step by step in the REXX programming language