Download Firebird 2.1 Release Notes
Transcript
New Built-in Functions
Function
Format
Description
POSITION( <string> IN <string> )
POSITION( <string>, <string> [, <offset-position>] )
select rdb$relation_name
from rdb$relations
where position('RDB$' IN rdb$relation_name) = 1;
/* */
position ('be', 'To be or not to be', 10)
returns 17. The first occurrence of 'be' occurs within the offset and is ignored.
position ('be', 'To buy or not to buy', 10)
returns 0 because the searched substring was not found.
POWER
POWER( <number>, <number> )
POWER(X, Y) returns X to the power of Y.
select power(x, 10) from y;
RAND
RAND() -- no argument
Returns a random number between 0 and 1.
select * from x order by rand();
REPLACE
REPLACE( <stringtosearch>,
<findstring>, <replstring> )
Replaces all occurrences of <findstring> in <stringtosearch> with <replstring>.
select replace(x, ' ', ',') from y;
REVERSE
REVERSE( <value> )
Returns a string in reverse order. Useful function
for creating an expression index that indexes strings
from right to left.
create index people_email on people
computed by (reverse(email));
select * from people
where reverse(email) starting with reverse('.br');
RIGHT
RIGHT( <string>, <number> )
Returns the substring, of the specified length, from
the right-hand end of a string.
select right(rdb$relation_name, char_length(rdb$relation_name) - 4)
from rdb$relations
where rdb$relation_name like 'RDB$%';
163