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

Implementation of static website layout in docker container

Server placement It is recommended to use cloud s...

Detailed explanation of using echarts map in angular

Table of contents Initialization of echart app-ba...

How to configure Java environment variables in Linux system

Configure Java environment variables Here, the en...

Detailed explanation of the use of React list bar and shopping cart components

This article example shares the specific code of ...

Analysis of the principle and creation method of Mysql temporary table

This article mainly introduces the principle and ...

JavaScript mobile H5 image generation solution explanation

Now there are many WeChat public account operatio...

Deploy Confluence with Docker

1. Environmental requirements 1. Docker 17 and ab...

Web page HTML code: production of scrolling text

In this section, the author describes the special...

Summary of some efficient magic operators in JS

JavaScript now releases a new version every year,...

React uses routing to redirect to the login interface

In the previous article, after configuring the we...

js returns to the previous page and refreshes the code

1. Javascript returns to the previous page history...

Docker Compose network settings explained

Basic Concepts By default, Compose creates a netw...

How to configure Hexo and GitHub to bind a custom domain name under Windows 10

Hexo binds a custom domain name to GitHub under W...