当前位置:网站首页>SQL functions STR
SQL functions STR
2022-08-01 12:42:00 【The user 7741497】
SQL function STR
A function to convert a number to a string.
Outline
STR(number[,length[,decimals]])
parameter
number
- An expression that resolves to a number.It can be a field name, a number, or the result of other functions.If a field name is specified, a logical value is used.length
- optional - an integer specifying the total length of the desired output string, including all characters (numbers, decimal points, symbols, spaces).The default value is10
.decimals
- optional — an integer specifying the number of digits to the right of the decimal point to include.The default value is 0.
Description
STR
Converts a number to STRING
format, truncating the number based on the length and decimal value.The length parameter must be large enough to contain the entire integer portion of the number and, if a decimal is specified, the number of decimal places plus 1
(for the decimal point).If the length is not large enough, STR
will return an asterisk (*
) string equal to the length.
STR
Converts numbers to their canonical form before string conversion.Therefore, it performs arithmetic operations, removing leading and trailing zeros and leading plus signs from the number.
If the number
parameter is NULL
, STR
returns NULL
.If the number
parameter is an empty string (''
), STR
returns an empty string.STRING
spaces are reserved.
Example
In the following embedded SQL
example, STR
converts a number to a string:
/// d ##class(PHA.TEST.SQLFunction).Str()ClassMethodStr(){&sql(SELECT STR(123),STR(123,4),STR(+00123.45,3),STR(+00123.45,3,1),STR(+00123.45,5,1)INTO :v,:w,:x,:y,:z)if SQLCODE '= 0 {w !,"Error code ",SQLCODE} else {w !,"Resulting STR:",v,"string"w !,"Resulting STR:",w,"string"w !,"Resulting STR:",x,"string"w !,"Resulting STR:",y,"string"w !,"Resulting STR:",z,"string"}}
DHC-APP>d ##class(PHA.TEST.SQLFunction).Str()Resulting STR: 123 stringResulting STR: 123 stringResulting STR: 123 stringResulting STR:*** stringResulting STR:123.4 string
The first STR
function returns a string consisting of 7
leading spaces and the number 123
; the seven leading spaces are becauseThe default string length is 10
.The second STR
function returns the string "123"
; note the leading whitespace required to return a string of length 4
.The third STR
function returns the string “123”
; the number is put into canonical form, and the decimal defaults to 0
.The fourth STR
function returns "***"
because the string is not long enough to contain the entire number specified; the number of asterisks indicates the string length.The fifth STR
function returns "123.4"
; note that the length must be 5
to contain decimal digits.
边栏推荐
- 2022 Go生态圈 rpc 框架 Benchmark
- 关于亚马逊测评,你了解多少?
- sql中ddl和dml(数据库表与视图的区别)
- R language fitting ARIMA model: use the auto.arima function in the forecast package to automatically search for the best parameter combination, model order (p, d, q), set the seasonal parameter to spe
- The CAN communication standard frame and extended frame is introduced
- SQL函数 STR
- 大中型网站列表页翻页过多怎么优化?
- 数字证书原理
- SQL函数 SQRT
- 快速幂---学习笔记
猜你喜欢
随机推荐
【StoneDB Class】入门第二课:StoneDB 整体架构解析
通讯录(静态版)(C语言)(VS)
MarkDown公式指导手册
Process sibling data into tree data
SQL函数 STR
英特尔全方位打造算力基础,助推“算”赋百业
sql中ddl和dml(数据库表与视图的区别)
HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
【Unity3D插件】AVPro Video插件分享《视频播放插件》
.NET性能优化-使用SourceGenerator-Logger记录日志
[Community Star Selection] Issue 24 August Update Plan | Keep writing, refuse to lie down!More original incentive packages, as well as Huawei WATCH FIT watches!
The use of Ts - Map type
Apex installation error
formatdatetime function mysql (date sub function)
JS数据类型转换完全攻略
Visualization of lag correlation of two time series data in R language: use the ccf function of the forecast package to draw the cross-correlation function, and analyze the lag correlation according t
Qt get all files in a folder
如何获取微信视频号的地址(微信公众号的链接地址)
[Nodejs] fs module of node
STM32 CAN过滤器配置详解