Home » SQL & PL/SQL » SQL & PL/SQL » New line while assigning value to a variable
New line while assigning value to a variable [message #277189] Mon, 29 October 2007 03:34 Go to next message
khresmoi
Messages: 24
Registered: October 2007
Junior Member
Hi,
i've a variable which is of varchar2 datatype and used inside a loop. design is such that a string is appended to the existing variable upon each round of execution of the loop; which can be represented as below.
v_erc := v_erc || string

but the problem is that a new line is needed between v_erc and string. Could you please help me with this?

TIA...
Re: New line while assigning value to a variable [message #277191 is a reply to message #277189] Mon, 29 October 2007 03:40 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
Just insert the linefeed ?

SELECT 'yappa' || Chr(13) || 'dappadu' FROM dual;


or

SELECT 'yappa' || chr(10) || Chr(13) || 'dappadu' FROM dual;


depending on whether you need the unix or windows one.


Re: New line while assigning value to a variable [message #277192 is a reply to message #277189] Mon, 29 October 2007 03:41 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
A newline has ASCII value 10. So, if you concatenate CHR(10) to your string, you'll be fine:
SQL> select 'a'||chr(10)||'b' thetext from dual;

THE
---
a
b
MHE
Re: New line while assigning value to a variable [message #277194 is a reply to message #277189] Mon, 29 October 2007 03:50 Go to previous messageGo to next message
Michel Cadot
Messages: 64111
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Or just put a newline in your string:
SQL> select 'a
  2  b' from dual
  3  /
'AB
---
a
b

1 row selected.

Regards
Michel
icon14.gif  Re: New line while assigning value to a variable [message #277197 is a reply to message #277189] Mon, 29 October 2007 03:54 Go to previous message
khresmoi
Messages: 24
Registered: October 2007
Junior Member
got it.. Thnx guys! Smile
Previous Topic: Regional Settings
Next Topic: Does The Query get Fired Again
Goto Forum:
  


Current Time: Mon Dec 05 13:08:18 CST 2016

Total time taken to generate the page: 0.07600 seconds