当前位置:网站首页>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.
边栏推荐
- 将同级数据处理成树形数据
- 关于亚马逊测评,你了解多少?
- Fault 007: The dexp derivative is inexplicably interrupted
- Envoy 源码流程图
- How to Integrate Your Service Registry with Istio?
- AI目标分割能力,无需绿幕即可实现快速视频抠图
- 判断JS数据类型的四种方法
- Pytest e-commerce project combat (below)
- bat countdown code
- [5 days countdown] to explore the secret behind the great quality promotion, gift waiting for you to take of $one thousand
猜你喜欢
随机推荐
Aeraki Mesh Joins CNCF Cloud Native Panorama
(ES6以上以及TS) Map对象转数组
formatdatetime函数 mysql(date sub函数)
浏览器存储
(ES6 and above and TS) Map object to array
Apex installation error
R语言检验时间序列的平稳性:使用tseries包的adf.test函数实现增强的Dickey-Fuller(ADF)检验、检验时序数据是否具有均值回归特性(平稳性)、具有均值回归特性的案例
SQL函数 %SQLSTRING
Js手写函数之new的模拟实现
How much do you know about Amazon reviews?
Grafana 9.0 released, Prometheus and Loki query builders, new navigation, heatmap panels and more!
一文带你彻底厘清 Isito 中的证书工作机制
2022 Go ecosystem rpc framework Benchmark
HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
Towhee 每周模型
如何获取微信视频号的地址(微信公众号的链接地址)
【云享新鲜】社区周刊·Vol.73- DTSE Tech Talk:1小时深度解读SaaS应用系统设计
leetcode/子矩阵元素和
数据湖 delta lake和spark版本对应关系
安全又省钱,“15岁”老小区用上管道燃气









