函数列表

<p>规则引擎提供了多种函数,您可以在编写SQL时使用它们,实现多样化数据处理。</p> <p>例如以下示例中,用到了deviceName()、floor(number)、topic(number)三个函数。</p> <p>SELECT case flag when 1 then &#39;开灯&#39; when 2 then &#39;关灯&#39; else &#39;&#39; end flag,deviceName(),floor(temperature) tmr FROM &quot;/topic/#&quot; WHERE temperature&gt;10 and topic(2)=&#39;123&#39;。</p> <table border="1" cellpadding="0" cellspacing="0" style="width:100%"> <tbody> <tr> <td style="background-color:#ededed"> <p><strong>函数名</strong><strong>&nbsp;</strong></p> </td> <td style="background-color:#ededed"> <p><strong>函数说明</strong><strong>&nbsp;</strong></p> </td> </tr> <tr> <td> <p>&nbsp;upper(string)</p> </td> <td> <p>&nbsp;返回大写string</p> </td> </tr> <tr> <td> <p>&nbsp;lower(string)</p> </td> <td> <p>&nbsp;返回小写string</p> </td> </tr> <tr> <td> <p>&nbsp;concat(string1,string2)</p> </td> <td> <p>&nbsp;返回string1+string2拼接后的字符串</p> </td> </tr> <tr> <td> <p>&nbsp;crypto(string1,encryType)</p> </td> <td> <p>&nbsp;返回加密后的string1,encryType可选MD2,MD5,SHA1,SHA-256,SHA-384,SHA-512中的一种,例如crypto(&quot;abc&quot;,&quot;MD5&quot;)</p> </td> </tr> <tr> <td> <p>&nbsp;endswith(string1,ffix)</p> </td> <td> <p>&nbsp;返回string1是否以ffix结尾</p> </td> </tr> <tr> <td> <p>&nbsp;startswith(string1,ffix)</p> </td> <td> <p>&nbsp;返回string1是否以ffix开头</p> </td> </tr> <tr> <td> <p>&nbsp;nanvl(object,default)</p> </td> <td> <p>&nbsp;如果object为空,返回default的值,否则返回object本身</p> </td> </tr> <tr> <td> <p>&nbsp;newuuid()</p> </td> <td> <p>&nbsp;返回一个随机的uuid</p> </td> </tr> <tr> <td> <p>&nbsp;payload(encodeType)</p> </td> <td> <p>&nbsp;返回设备发布消息的payload转字符串,字符编码默认UTF-8,即 payload()默认等价于payload(&quot;utf-8&quot;),否则按encodeType指定的编码格式返回</p> </td> </tr> <tr> <td> <p>&nbsp;replace(string1,oldstr,newstr)</p> </td> <td> <p>&nbsp;返回string1中oldstr替换成newstr后的字符串</p> </td> </tr> <tr> <td> <p>&nbsp;timestamp(format)</p> </td> <td> <p>&nbsp;返回当前系统时间,format可选,如果为空则返回当前系统时间戳毫秒值。比如 timestamp() = &quot;1232323233&quot;,timestamp(&quot;yyyy-MM-dd HH:mm:ss.SSS&quot;)=&quot;2016-05-30 12:00:00.000&quot;</p> </td> </tr> <tr> <td> <p>&nbsp;bitand(int1,int2)</p> </td> <td> <p>&nbsp;返回int1和int2按位与运算结果</p> </td> </tr> <tr> <td> <p>&nbsp;bitor(int1,int2)</p> </td> <td> <p>&nbsp;返回int1和int2按位或运算结果</p> </td> </tr> <tr> <td> <p>&nbsp;bitxor(int1,int2)</p> </td> <td> <p>&nbsp;返回int1和int2按位异或运算结果</p> </td> </tr> <tr> <td> <p>&nbsp;bitnot(int)</p> </td> <td> <p>&nbsp;返回int1按位取反运算结果</p> </td> </tr> <tr> <td> <p>&nbsp;chr(int)</p> </td> <td> <p>&nbsp;返回给定int参数对应的ASCII字符</p> </td> </tr> <tr> <td> <p>&nbsp;clientid()</p> </td> <td> <p>&nbsp;返回发送该消息的MQTT客户端ID</p> </td> </tr> <tr> <td> <p>&nbsp;isNull(object)</p> </td> <td> <p>&nbsp;判断object是否为空的布尔结果</p> </td> </tr> <tr> <td> <p>&nbsp;indexof(string1,string2)</p> </td> <td> <p>&nbsp;返回string1中string2的位置索引</p> </td> </tr> <tr> <td> <p>&nbsp;length(string)</p> </td> <td> <p>&nbsp;返回string字符长度</p> </td> </tr> <tr> <td> <p>&nbsp;trim(string)</p> </td> <td> <p>&nbsp;返回删除string所有前导和结尾空白后的字符串</p> </td> </tr> <tr> <td> <p>&nbsp;numbytes(string)</p> </td> <td> <p>&nbsp;返回输入字符串 UTF-8 编码中的字节数&nbsp;</p> </td> </tr> <tr> <td> <p>&nbsp;sin(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的正弦值</p> </td> </tr> <tr> <td> <p>&nbsp;cos(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的余弦值</p> </td> </tr> <tr> <td> <p>&nbsp;tan(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的正切值</p> </td> </tr> <tr> <td> <p>&nbsp;asin(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的反正弦值</p> </td> </tr> <tr> <td> <p>&nbsp;acos(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的反余弦值</p> </td> </tr> <tr> <td> <p>&nbsp;atan(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的反正切值</p> </td> </tr> <tr> <td> <p>&nbsp;sinh(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的双曲正弦值</p> </td> </tr> <tr> <td> <p>&nbsp;cosh(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的双曲余弦值</p> </td> </tr> <tr> <td> <p>&nbsp;tanh(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的双曲正切值</p> </td> </tr> <tr> <td> <p>&nbsp;toRadians(double)</p> </td> <td> <p>&nbsp;返回指定double类型角度值转换的弧度值</p> </td> </tr> <tr> <td> <p>&nbsp;toDegrees(double)</p> </td> <td> <p>&nbsp;返回指定double类型弧度值转换的角度值</p> </td> </tr> <tr> <td> <p>&nbsp;exp(double)</p> </td> <td> <p>&nbsp;返回自然数底数e的double类型参数次方</p> </td> </tr> <tr> <td> <p>&nbsp;log(double)</p> </td> <td> <p>&nbsp;返回double参数的自然数底数的对数值</p> </td> </tr> <tr> <td> <p>&nbsp;log10(double)</p> </td> <td> <p>&nbsp;返回以10为底的double参数的值</p> </td> </tr> <tr> <td> <p>&nbsp;log1p(double)</p> </td> <td> <p>&nbsp;返回ln(double + 1)的值</p> </td> </tr> <tr> <td> <p>&nbsp;sqrt(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的开方根</p> </td> </tr> <tr> <td> <p>&nbsp;cbrt(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数的立方根</p> </td> </tr> <tr> <td> <p>&nbsp;ceil(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数向上取整后的值</p> </td> </tr> <tr> <td> <p>&nbsp;floor(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数向下取整后的值</p> </td> </tr> <tr> <td> <p>&nbsp;rint(double)</p> </td> <td> <p>&nbsp;返回最接近指定double类型参数的整数值,返回值为double类型</p> </td> </tr> <tr> <td> <p>&nbsp;round(double)</p> </td> <td> <p>&nbsp;返回指定double类型参数四舍五入后的值,返回值为int类型</p> </td> </tr> <tr> <td> <p>&nbsp;atan2(double1,double2)</p> </td> <td> <p>&nbsp;返回矩形坐标 (double1, double2) 转换成极坐标 (r, theta),返回所得角 theta</p> </td> </tr> <tr> <td> <p>&nbsp;pow(double1,double2)</p> </td> <td> <p>&nbsp;返回double1参数的double2参数次方</p> </td> </tr> <tr> <td> <p>&nbsp;random()</p> </td> <td> <p>&nbsp;返回一个0-1之间的随机数</p> </td> </tr> <tr> <td> <p>&nbsp;abs(number)</p> </td> <td> <p>&nbsp;返回number的绝对值</p> </td> </tr> <tr> <td> <p>&nbsp;max(number1,number2)</p> </td> <td> <p>&nbsp;返回number1和number2参数中较大值</p> </td> </tr> <tr> <td> <p>&nbsp;min(number1,number2)</p> </td> <td> <p>&nbsp;返回number1和number2参数中较小值</p> </td> </tr> <tr> <td> <p>&nbsp;signum(double)</p> </td> <td> <p>&nbsp;返回指定double参数的符号函数(如果指定值为负,则返回-1;如果指定值为零,则返回 0;如果指定值为正,则返回1</p> </td> </tr> <tr> <td> <p>&nbsp;copySign(double1,double2)</p> </td> <td> <p>&nbsp;返回double2参数的符号和double1参数的值组成的新值</p> </td> </tr> <tr> <td> <p>&nbsp;deviceName()</p> </td> <td> <p>&nbsp;返回发送该消息的设备名称</p> </td> </tr> <tr> <td> <p>&nbsp;topic(int)</p> </td> <td> <p>&nbsp;返回Topic分段信息,比如有一个Topic:/abcdef/ghi,函数 topic() 返回 &quot;/abcdef/ghi&quot;, topic(1)&nbsp; 返回 &quot;abcdef&quot;, topic(2) 返回 &quot;ghi&quot;</p> </td> </tr> <tr> <td> <p>&nbsp;messageId()</p> </td> <td> <p>&nbsp;返回上报消息的消息id</p> </td> </tr> <tr> <td> <p>&nbsp;to_base64</p> </td> <td> <p>&nbsp;返回上报消息的base64编码</p> </td> </tr> </tbody> </table>
以上内容是否解决了您的问题?
请补全提交信息!
咨询·建议

电话咨询 - 7x24 小时

400-151-8800

邮件咨询

cloud@pingan.com

在线客服

7x24 小时,急速解答

工单支持

解决云产品相关技术问题