Use CHR(10)
We can insert newline into string using its ASCII value (i.e. 10). we can read about the CHR function here. Basically it forms the character from the given number. Let’s insert newline into our string using this. Here we will use the concatenation operator `||` to concatenate strings. See the following example.
Query:
INSERT INTO zoo VALUES (6, 'Wer', 'Zebra', 'A tall one.' || CHR(10) || 'With big black stripes.');
SELECT * FROM zoo;
Output:
Explanation: As we can see the newline character has been inserted into the string.
How to insert a line break in a String PL/SQL
In PL/SQL, inserting line breaks into VARCHAR or NVARCHAR strings can be a good way to enhance the readability and presentation of our data. Whether we are formatting output for display or preparing text for storage, knowing how to insert line breaks is a helpful skill. In this guide, we’ll explore the various techniques and examples for inserting line breaks in PL/SQL VARCHAR/NVARCHAR strings.