Oracle ROWIDTOCHAR() Function

Oracle ROWIDTOCHAR() is a built-in function that converts a given rowid value to VARCHAR2 type.

Oracle ROWIDTOCHAR() Syntax

Here is the syntax of the Oracle ROWIDTOCHAR() function:

ROWIDTOCHAR(rowid)

Parameters

rowid

Required.

Return Value

The Oracle ROWIDTOCHAR() function returns a string of 18 characters in length that is the string value of the given rowid.

If any parameter is NULL, ROWIDTOCHAR() returns NULL.

Oracle ROWIDTOCHAR() Examples

Here are some examples that demonstrate the usage of the Oracle ROWIDTOCHAR() function.

Basic Usage

The following statement converts a rowid value to a character value:

SELECT
    ROWIDTOCHAR('AAAACPAABAAAAWRAAA')
FROM dual;

输出:

ROWIDTOCHAR('AAAACPAABAAAAWRAAA')
____________________________________
AAAACPAABAAAAWRAAA

Here is a better example:

SELECT
    ROWID,
    DUMP(ROWID, 17, 1, 1),
    DUMP(ROWIDTOCHAR(ROWID), 17, 1, 1)
FROM dual;

输出:

ROWID                 DUMP(ROWID,17,1,1)    DUMP(ROWIDTOCHAR(ROWID),17,1,1)
_____________________ _____________________ __________________________________
AAAACPAABAAAAWRAAA    Typ=69 Len=10: ^@     Typ=1 Len=18: A

NULL Parameter

If any parameter is NULL, ROWIDTOCHAR() returns NULL.

SET NULL 'NULL';
SELECT
    ROWIDTOCHAR(NULL)
FROM dual;

输出:

ROWIDTOCHAR(NULL)
____________________
NULL

In this example, we use the SET NULL 'NULL'; statement to display the NULL value as the string 'NULL'.

Conclusion

Oracle ROWIDTOCHAR() is a built-in function that converts a given rowid value to VARCHAR2 type.