当前位置:网站首页>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 stringThe 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.
边栏推荐
- MVVM响应式
- Complete Raiders of JS Data Type Conversion
- 新一代超安全蜂窝电池, 思皓爱跑上市13.99万元起售
- R语言两个时间序列数据的滞后相关性可视化:使用forecast包的ccf函数绘制交叉相关函数,根据可视化结果分析滞后相关性
- Favorites|Mechanical Engineer Interview Frequently Asked Questions
- Towhee 每周模型
- Dameng replaces the officially authorized dm.key
- 通讯录(静态版)(C语言)(VS)
- 【面试高频题】难度 1.5/5,二分经典运用题
- 通配符SSL证书不支持多域名吗?
猜你喜欢

故障007:dexp导数莫名中断
![[Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement](/img/fc/cd859efa69fa7b45f173de74c04858.png)
[Open class preview]: Research and application of super-resolution technology in the field of video quality enhancement

【倒计时5天】探索音画质量提升背后的秘密,千元大礼等你来拿

Pytest电商项目实战(下)

Qt get all files in a folder

Dameng replaces the officially authorized dm.key
![[5 days countdown] to explore the secret behind the great quality promotion, gift waiting for you to take of $one thousand](/img/de/1e6069e84183d1400c90a6ec574f72.png)
[5 days countdown] to explore the secret behind the great quality promotion, gift waiting for you to take of $one thousand

HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界

关于Request复用的那点破事儿。研究明白了,给你汇报一下。

小程序插件如何帮助开发者受益?
随机推荐
腾讯云原生:Areaki Mesh 在 2022 冬奥会视频直播应用中的服务网格实践
Simulation implementation of new of Js handwritten function
大中型网站列表页翻页过多怎么优化?
How to integrate 3rd party service center registration into Istio?
批量任务导入到数据库中
数字证书原理
CloudCompare&PCL ICP配准(点到面)
Do wildcard SSL certificates not support multiple domains?
[5 days countdown] to explore the secret behind the great quality promotion, gift waiting for you to take of $one thousand
Several methods of appending elements are commonly used in js: append, appendTo, after, before, insertAfter, insertBefore, appendChild
【讲座分享】“营收“看金融
The four methods of judging JS data type
STM32 CAN过滤器配置详解
R language ggplot2 visualization: use ggpubr package ggscatter function visualization scatterplot, use xscale wasn't entirely specified X axis measurement adjustment function, set the X coordinate for
[Unity3D Plugin] AVPro Video Plugin Share "Video Player Plugin"
[Nodejs] node的fs模块
初级必备:单例模式的7个问题
Pytest电商项目实战(下)
浏览器存储
A new generation of ultra-safe cellular batteries, Sihao Airun goes on sale starting at 139,900 yuan