MYSQL custom function to determine whether it is a positive integer example code

MYSQL custom function to determine whether it is a positive integer example code

You can write a function: Mainly use regular expressions to make judgments. If the input character is empty, use "-" to replace it.

CREATE FUNCTION [dbo].[svf_NonNegativeInteger] (
 @val NVARCHAR(4000)
) RETURNS BIT
AS
BEGIN
  DECLARE
  @rtv BIT = 1
  SET @val = ISNULL(LTRIM(RTRIM(@val)), N'-')
  IF @val LIKE '%[^0-9]%' OR @val = N''
   SET @rtv = 0
  ELSE
   SET @rtv = 1
  RETURN @rtv
END

Example description:

Summarize

The above is the example code of the MYSQL custom function to determine whether it is a positive integer. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • MySQL custom function CREATE FUNCTION example
  • In-depth explanation of creating custom functions and stored procedures in MySQL
  • MySQL Chinese character conversion pinyin custom function and usage examples (first letter of the first word)
  • A brief discussion on mysql custom functions
  • How to use custom functions to extract numbers from strings in MySQL
  • Problems with creating custom functions in mysql
  • Simple usage examples of MySQL custom functions
  • Detailed explanation of the definition and usage of MySQL stored functions (custom functions)
  • Detailed explanation of MySQL custom functions and stored procedures
  • MySQL uses custom functions to recursively query parent ID or child ID
  • Analysis of the principle and usage of MySQL custom functions

<<:  How to install Django in a virtual environment under Ubuntu

>>:  How to completely uninstall iis7 web and ftp services in win7

Recommend

How to run Linux commands in the background

Normally, when you run a command in the terminal,...

Tkinter uses js canvas to achieve gradient color

Table of contents 1. Use RGB to represent color 2...

Summary of methods to improve mysql count

I believe many programmers are familiar with MySQ...

Solve the problem of Docker starting Elasticsearch7.x and reporting an error

Using the Docker run command docker run -d -p 920...

Example usage of JavaScript tamper-proof object

Table of contents javascript tamper-proof object ...

The most common mistakes in HTML tag writing

We better start paying attention, because HTML Po...

Deep understanding of the mechanism of CSS background-blend-mode

This article is welcome to be shared and aggregat...

How to set the memory size of Docker tomcat

When installing Tomcat in Docker, Tomcat may over...

MySQL date processing function example analysis

This article mainly introduces the example analys...

A simple example of MySQL joint table query

MySql uses joined table queries, which may be dif...

Detailed explanation of linux crm deployment code

Linux basic configuration Compile and install pyt...

MySql 8.0.11-Winxp64 (free installation version) configuration tutorial

1. Unzip the zip package to the installation dire...

Summary of basic usage of CSS3 @media

//grammar: @media mediatype and | not | only (med...