title: Complex TTITLE expressions in Oracle SQLPlus reports
body: <p>I'm writing a SQLPlus report in which the recurring header contains an address for a business, followed by several relevant rows regarding that business, followed by the address for the next business:</p>
  
  <pre><code>BOB'S GUITARS 
  123 SESAME STREET 
  NEW YORK, NY 10001
  
  customer name   last purchase date   last purchase amount
  -------------   ------------------   --------------------
  
  DAVE'S CIGARS 
  456 MOCKINGBIRD LANE 
  WASHINGTON, DC 12345
  
  customer name   last purchase date   last purchase amount
  -------------   ------------------   --------------------
  </code></pre>
  
  <p>The problem is this:</p>
  
  <p>Some of those businesses have multi-line addresses, while others do not.</p>
  
  <p>I can handle the basic case with something like
  <code>TTITLE CENTER BUSINESSNAME SKIP 1 CENTER ADDR1 SKIP 1 CENTER CITY</code></p>
  
  <p>(where "CITY" is a variable containing city, state, and zip)</p>
  
  <p>But I'm having a hard time figuring out how to put "add the second address line if ADDR2 is not null" without risking a blank line between ADDR1 and CITY.</p>
  
  <p>In other words, I don't want</p>
  
  <pre><code>BOB'S GUITARS
  123 SESAME STREET
  
  NEW YORK, NY 10001
  </code></pre>
  
  <p>in order to support</p>
  
  <pre><code>DAVE'S CIGARS
  456 MOCKINGBIRD LANE
  SUITE 101
  WASHINGTON, DC 12345
  </code></pre>
  
  <p><strong>EDIT / ADDITION</strong>:
  The suggestion of the combination of nvl and decode was the right first step, but now I've run into the problem that the two-line "line" in question exceeds the report's LINEWIDTH, and therefore gets truncated to LINEWIDTH character.  Here's the code I'm using to generate that line. Remember that both lines must be centered:</p>
  
  <pre><code>SELECT RPAD(' ', (79 - length(trim(address)))/2) 
    || trim(address) 
    || decode(nvl(trim(address_2), '='), '=', '', 
      CHR(10) 
      || RPAD(' ', (79 - length(trim(address_2)))/2, '-') 
      || trim(address_2) || ' ') ADDR1 from business
  </code></pre>