Skip Headers
Oracle® OLAP DML Reference
10g Release 2 (10.2)

Part Number B14346-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

REPLBYTES

The REPLBYTES function replaces one or more bytes in a text expression.

Tip:

When you are using a single-byte character set, you can use the REPLCHARS function instead of the REPLBYTES function. Also, o change one or more occurrences of a specified string in a text value to another string, use the CHANGECHARS function

Return Value

TEXT

Syntax

REPLBYTES(text-expression replacement [start])

Arguments

text-expression

A TEXT expression in which REPLBYTES replaces bytes. When the bytes to replace from text-expression contain embedded line breaks, these breaks are removed. Other line breaks are preserved. Removed line breaks are not counted toward the total number of bytes replaced. Line breaks in the replacement expression are retained in the output of REPLBYTES, but are likewise not counted.

Tip:

When you must use this function on NTEXT values, use the CONVERT or TO_CHAR function to convert the NTEXT value to TEXT.
replacement

A text expression that contains one or more bytes that will replace existing bytes in text-expression.

start

An INTEGER that represents the byte position at which to begin replacing bytes. The position of the first byte in text-expression is 1. When you omit this argument, REPLBYTES starts with the first byte. REPLBYTES replaces as many bytes of text-expression as are required for the bytes specified by replacement. When the value of start is greater than the length of text-expression, REPLBYTES simply returns text-expression.

Examples

Example 22-22 Replacing Text as Bytes

This example shows how to replace a portion of the text value Hello there, Joe.

The statement

SHOW REPLBYTES('Hello there, Joe', 'Jane', 14)

produces the following output.

Hello there, Jane

Example 22-23 How REPLBYTES Handles Line Breaks

This example shows how REPLBYTES preserves but ignores line breaks.

var1 = JOINLINES('Hello' 'there' 'Joe')
var2 = JOINLINES('Hi' 'Jane')

The statement

SHOW REPLBYTES(var1 var2)

produces the following output.

Hi
Janehere
Joe

REPLBYTES has replaced the first 6 bytes of var1 (Hellot of HellothereJoe) with the 6 bytes of var2 (HiJane). It has preserved the line breaks following Hi (from var2) and there (from var1).

To replace all 13 bytes in var1, you must specify 13 replacement bytes; for example, you can add 7 spaces after Jane.

var2 = JOINLINES('Hi' 'Jane       ')

The statement

SHOW REPLBYTES(var1 var2)

produces the following output.

Hi
Jane