InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference  /  SQL Functions

InterSystems SQL Reference
Previous section           Next section
InterSystems: The power behind what matters   

A string function that returns a string of spaces.
{fn SPACE(count)}
count An integer expression specifying the number of blank spaces to return.
SPACE returns a string of blank spaces count spaces long. If count is a numeric string, a decimal number, or a mixed numeric string, InterSystems IRIS resolves it to its integer portion. If count is a negative number or a nonnumeric string, InterSystems IRIS resolves it to 0.
To remove blank spaces from a string, use LTRIM (leading blanks) or RTRIM (trailing blanks).
The SPACE function should not be confused with the SPACE collation type. SPACE collation appends a single space to a value, forcing it to be evaluated as a string. To establish SPACE collation, CREATE TABLE provides a %SPACE collation keyword, and ObjectScript provides the Collation() method of the %SYSTEM.Util class.
The following embedded SQL example returns a string of spaces the length of the name field:
   &sql(SELECT SPACE(LENGTH(name))
   INTO :a
   FROM Sample.Person)
   IF SQLCODE'=0 {
     WRITE !,"Error code ",SQLCODE }
   ELSE {
     WRITE !,"Leave this much space:",a,"for names" }
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-20 05:47:55