Home » SQL & PL/SQL » SQL & PL/SQL » display in next line
display in next line [message #246893] Fri, 22 June 2007 06:52 Go to next message
soujanya_srk
Messages: 111
Registered: November 2006
Location: HYDERABAD
Senior Member
i have a code like this


declare

v_abc varchar2(40):='this is it';
v_xyz varchar2(40):='yes';


begin


 v_xyz:= v_xyz ||to_char(sysdate,'YYYY-DD HH:MI:SS AM ') || v_abc ||'||';
 
dbms_output.put_line(v_xyz);

end;


is there a way that the value in v_abc appears in next line?

the change has to be made in to_char itself...but i am not
sure how..

can anyone please tell me
Re: display in next line [message #246899 is a reply to message #246893] Fri, 22 June 2007 07:14 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Try this

v_xyz:= v_xyz ||to_char(sysdate,'YYYY-DD HH:MI:SS AM ') || chr(10)||v_abc ||'||';


chr(10) is a new line
chr(13) is a carraige return
Re: display in next line [message #246906 is a reply to message #246893] Fri, 22 June 2007 07:43 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Just go the next line:
v_xyz:= v_xyz ||to_char(sysdate,'YYYY-DD HH:MI:SS AM ') || '
'||v_abc ||'||';

Regards
Michel
Re: display in next line [message #246908 is a reply to message #246893] Fri, 22 June 2007 07:44 Go to previous messageGo to next message
soujanya_srk
Messages: 111
Registered: November 2006
Location: HYDERABAD
Senior Member
by carriage return, u mean that if the text which is to be
displayed in the next line is of size varchar2(2500),
then it will be divided into lines?

so if i use


declare
v_abc varchar2(4000):='this is a secure message and it is veryyyyyyyyyyyyyyyyyyy biggggggggggggggggggggggggggggggggggg';
v_xyz varchar2(4000):='yes';
begin
 v_xyz:= v_xyz ||to_char(sysdate,'YYYY-DD HH:MI:SS AM ') || chr(10)||chr(13)||v_abc ||'||';
dbms_output.put_line(v_xyz);
end;
/




that means, not just printing it in next line, but also
breaking them?
Re: display in next line [message #246909 is a reply to message #246893] Fri, 22 June 2007 07:45 Go to previous messageGo to next message
soujanya_srk
Messages: 111
Registered: November 2006
Location: HYDERABAD
Senior Member
and if so, the breaking depends on what rules?
Re: display in next line [message #246914 is a reply to message #246893] Fri, 22 June 2007 07:58 Go to previous messageGo to next message
soujanya_srk
Messages: 111
Registered: November 2006
Location: HYDERABAD
Senior Member
what exactly is carriage return?
Re: display in next line [message #246917 is a reply to message #246893] Fri, 22 June 2007 08:04 Go to previous messageGo to next message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
How about playing around with it to see what it does
Re: display in next line [message #246918 is a reply to message #246893] Fri, 22 June 2007 08:07 Go to previous messageGo to next message
soujanya_srk
Messages: 111
Registered: November 2006
Location: HYDERABAD
Senior Member


declare
v_abc varchar2(4000):='this is a secure message and it is veryyyyyyyyyyyyyyyyyyy biggggggggggggggggggggggggggggggggggg';
v_xyz varchar2(4000):='yes';
begin
 v_xyz:= v_xyz ||to_char(sysdate,'YYYY-DD HH:MI:SS AM ') || chr(10)||chr(13)||v_abc ||'||';
dbms_output.put_line(v_xyz);
end;
/






SQL> ed
Wrote file afiedt.buf

  1  declare
  2  v_abc varchar2(4000):='this is a secure message and it is veryyyyyyyyyyyyyyyyyyy biggggggggggggggggggggggggggggggggggg';
  3  v_xyz varchar2(4000):='yes';
  4  begin
  5   v_xyz:= v_xyz ||to_char(sysdate,'YYYY-DD HH:MI:SS AM ') || chr(10)||chr(13)||v_abc ||'||';
  6  dbms_output.put_line(v_xyz);
  7* end;
SQL> 
SQL> /
yes2007-22 06:38:27 PM 

this is a secure message and it is
veryyyyyyyyyyyyyyyyyyy biggggggggggggggggggggggggggggggggggg||

PL/SQL procedure successfully completed.

SQL> 


so it breaks the big line
Re: display in next line [message #246919 is a reply to message #246893] Fri, 22 June 2007 08:09 Go to previous message
MarcL
Messages: 455
Registered: November 2006
Location: Connecticut, USA
Senior Member
Because you told it to, you do not need both the chr(10)
and chr(13), one or the other will do.

Generally chr(10) is used unless you are feeding an application which is explicitly looking for a carriage return character.

Previous Topic: Records from sql server to Oracle
Next Topic: REGEXP - ignore spaces
Goto Forum:
  


Current Time: Sun Dec 11 02:12:02 CST 2016

Total time taken to generate the page: 0.11808 seconds