SAPHANA学习(10):SQL Function(I)
75.IFNULL
IFNULL(<expression1>, <expression2>)
返回第一个非空表达式
*/
SELECT IFNULL('diff', 'same') FROM DUMMY; SELECT IFNULL(NULL, 'same') FROM DUMMY; SELECT IFNULL(NULL, NULL) FROM DUMMY;
/*
76.INDEXING_ERROR_CODE
INDEXING_ERROR_CODE(<column_name>)
返回具有全文索引列的值的错误代码
INDEXING_ERROR_MESSAGE(<column_name>)
返回具有全文索引列值的错误信息
INDEXING_STATUS(<column_name>)
Status值说明:
ERROR - the value could not be indexed due to a mismatch in the data type
INDEXED - the value is been indexed
QUEUED - the value is queued for indexing
*/
CREATE COLUMN TABLE TEST_INDEX_ERROR_CODE (CONTENT varchar(50)); CREATE FULLTEXT INDEX I ON TEST_INDEX_ERROR_CODE(CONTENT) ASYNC MIME TYPE 'text/xml' FAST PREPROCESS OFF; INSERT INTO TEST_INDEX_ERROR_CODE VALUES ('This is an example'); INSERT INTO TEST_INDEX_ERROR_CODE VALUES ('<xml>This is an example</xml>'); –- Wait a few seconds SELECT INDEXING_ERROR_CODE(CONTENT),CONTENT FROM TEST_INDEX_ERROR_CODE; SELECT INDEXING_ERROR_MESSAGE(CONTENT),CONTENT FROM TEST_INDEX_ERROR_CODE; SELECT INDEXING_STATUS(CONTENT),CONTENT FROM TEST_INDEX_ERROR_CODE; --QUEUED 排序 ALTER FULLTEXT INDEX I SUSPEND QUEUE; INSERT INTO TEST_INDEX_ERROR_CODE VALUES ('<xml>its INDEXING_STATUS is QUEUED</xm>'); SELECT INDEXING_STATUS(CONTENT),CONTENT FROM TEST_INDEX_ERROR_CODE;
/*
77.INITCAP
INITCAP(<inputString>)
将字符串首字母大写,其余小写
<inputString> can be either a VARCHAR or NVARCHAR value.
*/
--不存在?? --SELECT INITCAP('the EXAMPLE one') FROM DUMMY;
/*
78.IS_SQL_INJECTION_SAFE(<value>[, <max_tokens>])
检查SQL是否存在注入风险
<max_tokens>:最大风险字符个数,如果超过返回0(not safe),没有超过返回1
这些是风险字符
空格 , ( ) [ ] . ; : + - * / % ^ < > =
*/
SELECT IS_SQL_INJECTION_SAFE('tab,le') FROM DUMMY; SELECT IS_SQL_INJECTION_SAFE('CREATE STRUCTURED PRIVILEGE', 3) FROM DUMMY; --存在注释/*不安全 SELECT IS_SQL_INJECTION_SAFE('mytab /*', 4) FROM DUMMY;
/*
79.ISOWEEK
ISOWEEK(<date>)
返回ISO年,周信息<date>
week数字前有W字母
*/
SELECT ISOWEEK(TO_DATE('2011-05-30', 'YYYY-MM-DD')) FROM DUMMY;
本文来自博客园,作者:渔歌晚唱,转载请注明原文链接:https://www.cnblogs.com/tangToms/p/13886763.html