Skip to main content
Converts a value (<expression>) of type INTEGER or BIGINT to its equivalent octal representation.

Syntax

TO_OCT(<expression>)

Parameters

ParameterDescriptionSupported input types
<expression>A value expression evaluating to INTEGER or BIGINT that should be converted.INTEGER, BIGINT

Return Type

TEXT
  • Returns NULL if input is NULL

Remarks

The function returns the octal representation of the input number as a text string. Negative numbers are displayed as the octal representation of their binary two’s complement form. Leading zeros are omitted, but the output is at least one digit long.

Example

The following examples convert integer values to their octal representations:
SELECT TO_OCT(42) as result
result text
52

Rows: 1Execution time: 5.01ms

SELECT TO_OCT(-1) as result
result text
37777777777

Rows: 1Execution time: 5.19ms

SELECT TO_OCT(0) as result
result text
0

Rows: 1Execution time: 5.25ms

SELECT TO_OCT(NULL) as result
result text null
NULL

Rows: 1Execution time: 5.37ms