Previous Topic: Built-In FunctionsNext Topic: Parameters Of Built-In Functions


Invoking Built-In Functions

Built-in functions are invoked by specifying an invocation name.

There are five types of built-in functions: aggregate, arithmetic, date, string, and trigonometric. For a list of built-in functions and what they do, see the tables below.

Where you use them:

You can specify arithmetic, date, string, and trigonometric built-in functions in CA OLQ anywhere you would normally specify arithmetic or comparison expressions. You can specify aggregate built-in functions in a:

Table 5: CA OLQ Aggregate Built-In Functions

Function

Invocation

Example

Return the average (median) value

AVERAGE

AVE

compute ave-sal = ave(salary) group by dept

Return the number of elements

COUNT

COU

NUMBER

NUM

select count(*) from employee group by dept

Return the highest value

MAXIMUM

MAX

HIVAL

HIV

select max(salary) as 'Top Salary' from employee group by dept

Return the lowest value

MINIMUM

MIN

LOVAL

LOV

select min(salary) as 'Low Sal' from employee

group by dept

Return the product for all values of a break

PRODUCT

PROD

select product (interest-rate) from mutual-funds

group by all

Return the sum of all values

TOTAL

SUM

select sum(salary) as 'Total Salaries' from employee group by dept

Return the sample standard deviation of all values

STD

select std(salary) as 'Standard Deviation Based on Sample' from employee group by job-id

Return the population standard deviation of all values

STDP

select stdp(salary) as 'Standard Deviation Based on Population' from employee group by job-id

Return the sample variance of all values

VAR

select var(salary) as 'Variance Based on Sample' from employee group by job-id

Return the population variance of all values

VARP

select varp(salary) as 'Variance Based on Population' from employee group by job-id

Table 6: CA OLQ Arithmetic Built-In Functions

Function

Invocation

Example

Return the absolute value of a number

ABSOLUTE-VALUE

ABS-VAL

@ABS

ABS

select abs(oper1) as 'Difference' from table1

Return the value of a number multiplied by -1

INVERT-SIGN

INVERT

INV

select inv(oper1) as 'Inverted Value' from table1

Return the natural logarithm of a number

LOG-BASE-E

LOGNAT

NATLOG

LOGE

@LN

select loge(oper1) as 'Log Base E' from table1

Return the common logarithm of a number

LOG-BASE-10

LOGCOM

COMLOG

LOG10

@LOG

select log10(oper1) as 'Log Base 10' from table1

Return the modulus (remainder) of a division operation

MODULO

MOD

@MOD

select mod(oper1 - oper2) as 'Remainder' from table1

Return the smallest integer that is equal to or greater than the specified number

NEXT-INT-EQHI

NEXTINTEH

NEXIH

@CEIL

select nexih(balance-due) as 'Balance Due' from invoice

Return the largest integer that is lower than the specified number

NEXT-INT-EQLO

NEXTINTEL

NEXIL

@TRUNC

@INT

select nexil(balance-due) as 'Balance Due' from invoice

Return a pseudo-random number based on a seed number

RANDOM-NUMBER

RANDOM

@RAND

RAN

compute 'number' = random (13549)

Return a +1, 0, or -1 depending on whether a number is positive, zero, or negative

SIGN-VALUE

SIGN-VAL

SIGV

select sigv(oper1) as 'Sign' from table1

Return the square root of a number

SQUARE-ROOT

@SQRT

SQRT

select sqrt(oper1) as 'Square Root' from table1

Table 7: CA OLQ Date Built-In Functions

Function

Invocation

Example

Return the conversion of a specified date from one format (Gregorian, calendar, European, or Julian) to another format

DATECHG DATECHGX

GCDATE GCDATEX

GJDATE GJDATEX

CEDATE CEDATEX

EGDATE EGDATEX

EJDATE EJDATEX

JCDATE JCDATEX

GEDATE GEDATEX

CGDATE CGDATEX

CJDATE CJDATEX

ECDATE ECDATEX

JGDATE JGDATEX

JEDATE JEDATEX

compute calendar = datechg(start-date,'G','C')

Return the number of days between two specified dates

DATEDIF

select datefig(start-date, end-date) as 'Senior' from table1

Return the date resulting from adding a specified number of days to a specified date

DATEOFF

compute newdate = dateoff(start-date,4)

Return today's date in the format requested

TODAY

TODAYX

select today('C') as 'Day-off'

Return tomorrow's date in the format requested

TOMORROW

TOMORROWX

select tomorrow('C') as 'Holiday'

Return the weekday (Monday, Tuesday, etc.) of a specified Gregorian, calendar, European, or Julian date

WEEKDAY

WEEKDAYX

GWEEKDAY

GWEEKDAYX

CWEEKDAY

CWEEKDAYX

EWEEKDAY

EWEEKDAYX

JWEEKDAY

JWEEKDAYX

compute weekday = weekday(birthday,'C')

Return yesterday's date in the format requested

YESTERDAY

YESTERDAYX

select yesterday('C') as 'Day-off'

Table 8: CA OLQ String Built-In Functions

Function

Invocation

Example

Return the concatenation of a specified list of strings

CONCATENATE

CONCAT

CON

select concatenate(emp-first-name,emp-last-name) from employee

Return the substring that results from removing leading and trailing spaces from a string

EXTRACT

EXT

select extract(emp-last-name) from employee

Return a fixed-length string of 20, 40, 60, or 80 characters

FIX20

FIX40

FIX60

FIX80

select fix40 concat((extract(emp-fname), ' ',extract(emp-lname))

Return the string resulting when the first letter in the specified source string is capitalized and all other characters in the string are converted to lowercase

INITCAP

compute new-emp-lname = initcap(emp-lname)

Return the string resulting from inserting one string into another

INSERT

INS

select insert(emp-name,'**',1) from employee where emp-city eq boston

Return the string that results from left justifying a string

LEFT-JUSTIFY

LEFT-JUST

LEFJUS

LEFT

select lefjus(emp-last-name) from employee

Return the starting position of a specified substring

STRING-INDEX

INDEX

INDX

select * from invoice where index(prod-code,'ABC') ne 0

Return the length of a string

STRING-LENGTH

SLENGTH

SLEN

select length(extract(emp-first-name)) from employee

Return the substring of a string, starting from a specified position, and continuing for a specified length

SUBSTRING

SUBSTR

SUBS

select substr(emp-id,3,2) from employee

Return the string that results from right justifying a string

RIGHT-JUSTIFY

RIGHT-JUST

RIGHTJUS

RIGHT

select rightjus(emp-name) from employee

Return the string that results from converting all characters to lowercase

TOLOWER

compute new-emp-lname = tolower(emp-lname)

Return the string that results from converting all characters to uppercase.

TOUPPER

compute new-emp-lname = toupper(emp-lname)

Return the string that results from translating characters in a string that also occur in a selection string to corresponding characters in a substitution string

TRANSLATE

TRANS

select trans (course-id,'123','abc') from course-list

Return the position of the first character in a string that doesn't occur in a second specified string

VERIFY

VER

select emp-name from employee where verify(emp-id, '1234567890 ') ne 0

Return the string resulting when the first letter of each word in the specified source string is capitalized and all other characters in the string are converted to lowercase

WORDCAP

compute new-emp-lname = wordcap(emp-lname)

Table 9: CA OLQ Trigonometric Built-In Functions

Function

Invocation

Example

Return the arc cosine of a number that represents an angle in degrees

ARCCOSINE-DEGREES

ARCCOSDEG

ACOSD

compute 'Arc Cosine' = acosd(angle-in-degrees)

Return the arc cosine of a number that represents an angle in radians

ARCCOSINE-RADIANS

ARCCOSRAD

ACOSR

compute 'Arc Cosine'= acosr(angle-in-radians)

Return the arc sine of a number that represents an angle in degrees

ARCSINE-DEGREES

ARCSINDEG

ASIND

compute 'Arc Sine' = asind(angle-in-degrees)

Return the arc sine of a number that represents an angle in radians

ARCSINE-RADIANS

ARCSINRAD

ASINR

compute 'Arc Sine' = asinr(angle-in-radians)

Return the arc tangent of a number that represents an angle in degrees

ARCTAN-DEGREES

ARCTANDEG

ATAND

compute 'Arc Tangent' = atand(angle-in-degrees)

Return the arc tangent of a number that represents an angle in radians

 

ARCTAN-RADIANS

ARCTANRAD

ATANR

:display. compute 'Arc Tangent' = atand(angle-in-radians)

Return the cosine of a number that represents an angle in degrees

COSINE-DEGREES

COSDEG

COSD

compute 'Cosine' = cosd(angle-in-degrees)

Return the cosine of a number that represents an angle in radians

COSINE-RADIANS

COSRAD

COSR

compute 'Cosine' = cosr(angle-in-radians)

Return the sine of a number that represents an angle in degrees

SINE-DEGREES

SINEDEG

SIND

compute 'Sine' = sind(angle-in-degrees)

Return the sine of a number that represents an angle in radians

SINE-RADIANS

SINERAD

SINR

compute 'Sine' = sinr(angle-in-radians)

Return the tangent of a number that represents an angle in degrees

TANGENT-DEGREES

TANDEG

TAND

compute 'Tangent' = tand(angle-in-degrees)

Return the tangent of a number that represents an angle in radians

TANGENT-RADIANS

TANRAD

TANR

compute 'Tangent' = tanr(angle-in-radians)