EJB 查询:标量函数
Enterprise JavaBeans (EJB) 查询包含用于执行类型转换、字符串处理和处理日期时间值的标量内置函数。
EJB 查询标量内置函数的详细信息如下:
数字函数
ABS ( < any numeric datatype > ) -> < any numeric datatype >
MOD ( <int>, <int> ) -> int
SQRT ( < any numeric datatype > ) -> Double
类型转换函数
CHAR ( < any numeric datatype > ) -> string CHAR ( < string > ) -> string CHAR ( < any datetime datatype > [, Keyword k ]) -> string
日期时间数据类型转换为以关键字 k 指定的格式的其字符串表示法,有效的关键字值为 ISO、USA、EUR 或 JIS。如果未指定 k,那么缺省值为 ISO。
BIGINT ( < any numeric datatype > ) -> Long BIGINT ( < string > ) -> Long
以下代码的第二行中的函数通过截断将自变量转换为整数 n,并返回 0001 年 1 月 1 日后 n-1 天的该日期:
DATE ( < date string > ) -> Date DATE ( < any numeric datatype>) -> Date
以下函数返回时间戳记的日期部分:
DATE( timestamp ) -> Date DATE ( < timestamp-string > ) -> Date
以下函数使
用可选精度 p 和比例 s 将数字转换为十进制数。
DECIMAL ( < any numeric datatype > [, p [ ,s ] ] ) -> Decimal
以下函数使用可选精度 p 和比例 s 将字符串转换为十进制。
DECIMAL ( < string > [ , p [ , s ] ] ) -> Decimal
DOUBLE ( < any numeric datatype > ) -> Double DOUBLE ( < string > ) -> Double
FLOAT ( < any numeric datatype > ) -> Double FLOAT ( < string > ) -> DoubleFloat 是 DOUBLE 的同义词。
INTEGER ( < any numeric datatype > ) -> Integer INTEGER ( < string > ) -> Integer
REAL ( < any numeric datatype > ) -> Float
SMALLINT ( < any numeric datatype ) -> Short SMALLINT ( < string > ) -> Short
TIME ( < time > ) -> Time TIME ( < time-string > ) -> Time TIME ( < timestamp > ) -> Time TIME ( < timestamp-string > ) -> Time
TIMESTAMP ( < timestamp > ) -> Timestamp TIMESTAMP ( < timestamp-string > ) -> Timestamp
String functions
CONCAT ( <string>, <string> ) -> String
以下函数返回代表不包括其正负号或十进制小数点的自变量的绝对值的字符串。例如,digits( -42.35) 为“4235”。
DIGITS ( Decimal d ) -> String
以下函数返回自变量的长度(以字节计)。如果自变量是一个数字或日期时间类型,那么它返回内部表示法的长度。
LENGTH ( < string > ) -> Integer
以下函数返回自变量字符串的副本,其中所有的大写字符都已转换为小写字符。
LCASE ( < string > ) -> String
以下函数返回带有可选开始位置的自变量 2 中的自变量 1 的首次发生的开始位置。如果未找到,那么它返回 0。
LOCATE ( String s1 , String s2 [, Integer start ] ) -> Integer
以下函数返回在字符 m 开始并包含 n 个字符的子字符串。如果省略 n,那么该子字符串包含其他字符串 s。如果需要做长度 n 的字符串,那么结果字符串用空白填充。
SUBSTRING ( String s , Integer m [ , Integer n ] ) -> String
以下函数返回自变量字符串的副本,其中所有小写字符都已转换为大写字符。
UCASE ( < string > ) -> String
日期-时间函数
以下函数返回其自变量的日期部分。对于持续时间,返回值可以是 -99 到 99。
DAY ( Date ) -> Integer DAY ( < date-string > ) -> Integer DAY ( < date-duration > ) -> Integer DAY ( Timestamp ) -> Integer DAY ( < timestamp-string > ) -> Integer DAY ( < timestamp-duration > ) -> Integer
以下函数将 0001 年 1 月的天数+1 的值返回到其自变量。
DAYS ( Date ) -> Integer DAYS ( < Date-string > ) -> Integer DAYS ( Timestamp ) -> Integer DAYS ( < timestamp-string > ) -> Integer
以下函数返回其自变量的小时部分。对于持续时间,返回值可以是 -99 到 99。
HOUR ( Time ) -> Integer HOUR ( < time-string > ) -> Integer HOUR ( < time-duration > ) -> Integer HOUR ( Timestamp ) -> Integer HOUR ( < timestamp-string > ) -> Integer HOUR ( < timestamp-duration > ) -> Integer
以下函数返回其自变量的微秒部分。
MICROSECOND ( Timestamp ) -> Integer MICROSECOND ( < timestamp-string > ) -> Integer MICROSECOND ( < timestamp-duration > ) -> Integer
以下函数返回其自变量的分钟部分。对于持续时间,返回值可以是 -99 到 99。
MINUTE ( Time ) -> Integer MINUTE ( < time-string > ) -> Integer MINUTE ( < time-duration > ) -> Integer MINUTE ( Timestamp ) -> Integer MINUTE ( < timestamp-string > ) -> Integer MINUTE ( < timestamp-duration > ) -> Integer
以下函数返回其自变量的月部分。对于持续时间,返回值可以是 -99 到 99。
MONTH ( Date ) -> Integer MONTH ( < date-string > ) -> Integer MONTH ( < date-duration > ) -> Integer MONTH ( Timestamp ) -> Integer MONTH ( < timestamp-string > ) -> Integer MONTH ( < timestamp-duration > ) -> Integer
以下函数返回其自变量的秒部分。对于持续时间,返回值可以是 -99 到 99。
SECOND ( Time ) -> Integer SECOND ( < time-string > ) -> Integer SECOND ( < time-duration > ) -> Integer SECOND ( Timestamp ) -> Integer SECOND ( < timestamp-string > ) -> Integer SECOND ( < timestamp-duration > ) -> Integer
以下函数返回其自变量的年部分。对于持续时
间,返回值可以是 -9999 到 9999。
YEAR ( Date ) -> Integer YEAR ( < date-string > ) -> Integer YEAR ( < date-duration > ) -> Integer YEAR ( Timestamp ) -> Integer YEAR ( < timestamp-string > ) -> Integer YEAR ( < timestamp-duration > ) -> Integer