{"id":321,"date":"2013-09-24T00:12:56","date_gmt":"2013-09-24T00:12:56","guid":{"rendered":"http:\/\/www.theSQLReport.com\/?p=321"},"modified":"2014-02-13T02:33:53","modified_gmt":"2014-02-13T02:33:53","slug":"sqlplus-newline-character","status":"publish","type":"post","link":"http:\/\/www.theSQLReport.com\/?p=321","title":{"rendered":"SQLPlus Newline Character"},"content":{"rendered":"<p>Not exactly one character will produce a new line in Oracle&#8217;s SQLPlus.\u00a0 By piping the ASCII CHR(13) then piping the ASCII CHR(10) in that order (\u00a0 || CHR(13) || CHR(10) || ) gives the query its desired result.\u00a0 This works on the Unix, Linux, and the Windows operating systems.\u00a0\u00a0 ASCII CHR(13) is the carriage return character.\u00a0 ASCII CHR(10) is the line feed character.<\/p>\n<p>Wikipedia provides a nice explanation on both the <a title=\"Carriage Return\" href=\"http:\/\/en.wikipedia.org\/wiki\/Carriage_return\" target=\"_blank\">carriage return<\/a> and the <a title=\"Line Feed\" href=\"http:\/\/en.wikipedia.org\/wiki\/Line_feed\" target=\"_blank\">line feed<\/a>.<\/p>\n<p>Shown in the example below are what the two characters together look like, and how each act when used independently.<\/p>\n<p>A simple query for SQLPlus:<\/p>\n<p><em>select &#8216;A system view is: &#8216; || view_name || &#8216;\u00a0 &#8216; || CHR(13) || CHR(10) || &#8216;&#8211; Line for Comments or Commit &#8211;&#8216; as COMMAND from all_views where owner = &#8216;SYS&#8217; and view_name like &#8216;ALL%&#8217;;<\/em><\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/simple_query.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-326 aligncenter\" alt=\"Simple Query\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/simple_query.jpg\" width=\"575\" height=\"109\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/simple_query.jpg 575w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/simple_query-300x56.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/simple_query-210x39.jpg 210w\" sizes=\"(max-width: 575px) 100vw, 575px\" \/><\/a><\/p>\n<p><strong>ASCII CHR(13) ||\u00a0 ASCII CHR(10) together:<\/strong><\/p>\n<p>Below is what the top three lines of the result set looks like on Unix\/Linux system:<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Linux_Both.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-335 aligncenter\" alt=\"Unix - Linux Both\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Linux_Both.jpg\" width=\"1010\" height=\"211\" \/><\/a><\/p>\n<p>By using the ASCII characters 13 &amp; 10 in that order, the result data can be moved between files among different operating systems and the appearance will not change.<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/notepad_both.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" alt=\"Notepad Pasted Results\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/notepad_both.jpg\" width=\"443\" height=\"332\" \/><\/a><\/p>\n<p><strong>ASCII CHR(10) alone:<\/strong><\/p>\n<p>Now if only the Line Feed character ASC(10) is used , it will display normally in SQLPlus on a Unix\/Linux system (example shown below).<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/ten_only_unix.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-328 aligncenter\" alt=\"ascii ten only\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/ten_only_unix.jpg\" width=\"1039\" height=\"265\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/ten_only_unix.jpg 1039w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/ten_only_unix-300x76.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/ten_only_unix-1024x261.jpg 1024w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/ten_only_unix-210x53.jpg 210w\" sizes=\"(max-width: 1039px) 100vw, 1039px\" \/><\/a><\/p>\n<p>However, when the result data is opened in a Windows operating system program, like notepad, the data will still be all on the same line.<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Ten_Only.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-327 aligncenter\" alt=\"Windows Ten Only\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Ten_Only.jpg\" width=\"682\" height=\"209\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Ten_Only.jpg 682w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Ten_Only-300x91.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/Ten_Only-210x64.jpg 210w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><\/p>\n<p><strong>ASCII CHR(13) alone:<\/strong><\/p>\n<p>If only the Line Feed (ASC(13)) is used , the results on a Unix\/Linux system overwrite the beginning of the line.<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thriteen_only.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-330 aligncenter\" alt=\"thriteen_only\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thriteen_only.jpg\" width=\"1037\" height=\"192\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thriteen_only.jpg 1037w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thriteen_only-300x55.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thriteen_only-1024x189.jpg 1024w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thriteen_only-210x38.jpg 210w\" sizes=\"(max-width: 1037px) 100vw, 1037px\" \/><\/a><\/p>\n<p>The result set also has the same results as using the ASC (10) character when view on the Windows operating system.<\/p>\n<p><a href=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thirteen_notepad.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-329 aligncenter\" alt=\"thirteen_notepad\" src=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thirteen_notepad.jpg\" width=\"680\" height=\"182\" srcset=\"http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thirteen_notepad.jpg 680w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thirteen_notepad-300x80.jpg 300w, http:\/\/www.theSQLReport.com\/wp-content\/uploads\/2013\/09\/thirteen_notepad-210x56.jpg 210w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Please note that the results may vary using different programs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Not exactly one character will produce a new line in Oracle&#8217;s SQLPlus.\u00a0 By piping the ASCII CHR(13) then piping the ASCII CHR(10) in that order (\u00a0 || CHR(13) || CHR(10) &hellip; <a class=\"readmore\" href=\"http:\/\/www.theSQLReport.com\/?p=321\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-321","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oracle"],"_links":{"self":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/321"}],"collection":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=321"}],"version-history":[{"count":21,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/321\/revisions"}],"predecessor-version":[{"id":365,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/posts\/321\/revisions\/365"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=\/wp\/v2\/media\/335"}],"wp:attachment":[{"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=321"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.theSQLReport.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}