How do I print a new line in PL/SQL? I'm after something similar to '\n' in the C language.
Example:
begin dbms_output.put_line('Hi, good morning friends'); end;
I need the output is like this:
hi, good morning friends
There is a function chr() that will take the ascii code and return the character. So, if you: myString := 'Some Text' || chr(10) || 'Some more Text....'; that'll build a string that has a newline (line feed) in it.
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)
In the DBMS Output window, choose the "plus" icon and select the connection that you want to write data to the DBMS Output window. Then run the PL/SQL block in the SQL Worksheet window using the right arrow (Ctrl+Enter in Windows). You'll see the output appear in the DBMS Output window.
You can concatenate the CR and LF:
chr(13)||chr(10)
(on windows)
or just:
chr(10)
(otherwise)
dbms_output.put_line('Hi,'||chr(13)||chr(10) ||'good' || chr(13)||chr(10)|| 'morning' ||chr(13)||chr(10) || 'friends');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With