Skip to main content

This version of the product is no longer supported, and this documentation is no longer updated regularly. See the latest version of this content.Opens in a new tab

SQUARE

A scalar numeric function that returns the square of a number.

Synopsis

SQUARE(numeric-expression)

Arguments

numeric-expression An expression that resolves to a numeric value.

Description

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.

Examples

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

FeedbackOpens in a new tab