Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Line while inserting into VARCHAR2 column

I have a requirement where i need to prepare data for email ,So i populate
data into column of table having VARCHAR2(4000) as definition, Now what i want, is to insert it into new line wherever i want to .

 begin
 v_email := v_email ||--new line--??;
 end;

Suppose i am preparing email text 'List of all blocked transaction id ' ..in one line 1)transaction_id ....in another lin e 2)transaction_id .....in another line.

I am using oracle as rdbms .

like image 864
gaurav Avatar asked Nov 07 '11 12:11

gaurav


People also ask

How do I add a new line character in Oracle?

Chr(Number) should work for you. Remember different platforms expect different new line characters: CHR(10) => LF, line feed (unix) CHR(13) => CR, carriage return (windows, together with LF)

Can VARCHAR2 hold special characters?

It can hold numbers, letters and special characters. Microsoft SQL Server 2008 (and above) can store up to 8000 characters as the maximum length of the string using varchar data type.

How do you create a new line in PL SQL?

SQL Server ' AS 'New Line' -- using carriage return: CHAR(13) SELECT 'First line. '+ CHAR(13) + 'Second line. ' AS 'New Line' -- Using both: CHAR(13)+CHAR(10) SELECT 'First line. '+ CHAR(13)+CHAR(10) + 'Second line.

What characters are allowed in VARCHAR2 Oracle?

It is used to store normal characters and alphanumeric characters too. The VARCHAR2 data type can store a character string of a maximum length of 4000 bytes of characters.


1 Answers

You could use the ASCII code and the CHR function to do this.

Here's the entire list. http://www.asciitable.com/

SQL> conn rc/rc@orcl102
Connected.
SQL> set serveroutput on;
SQL> begin
  2    dbms_output.put_line('Hello..' || chr(10) || 'how are you...');
  3  end;
  4  /
Hello..
how are you...
like image 119
Rajesh Chamarthi Avatar answered Oct 14 '22 14:10

Rajesh Chamarthi