Home / InterSystems SQL Reference / SQL Functions / SQUARE

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

A scalar numeric function that returns the square of a number.
numeric-expression An expression that resolves to a numeric value.
SQUARE returns either the NUMERIC or DOUBLE data type. If numeric-expression is data type DOUBLE, SQUARE returns DOUBLE; otherwise, it returns NUMERIC.
SQUARE returns the square of numeric-expression. SQUARE returns NULL if passed a NULL value.
The precision and scale returned by SQUARE are the same as those returned by the SQL multiplication operator.
The following Embedded SQL example returns the squares of the integers 0 through 10:
   SET a=0
   WHILE a<11 {
   &sql(SELECT SQUARE(:a) INTO :b)
   IF SQLCODE'=0 {
     WRITE !,"Error code ",SQLCODE
     QUIT }
   ELSE {
     WRITE !,"The square of ",a," = ",b
     SET a=a+1 }
See Also

Previous section           Next section
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-04-10 14:45:57