Use an "IF statement" on the "ORDER BY" in a report in INFORMIX 4GL
<p>I'm having a report which is called many times but I want the order to be different each time. </p>

<p>How can I change the "order by" depending on a variable.</p>

<p>For example</p>

<pre><code>report print_label()

   If is_reprint
   then
       order by rpt.item_code, rpt.description
   else
       order by rpt.description, rpt.item_code
   end if
</code></pre>

<p>I tried passing in a variable when calling the report:</p>

<pre><code>let scratch = "rpt.item_code, rpt.description"
start print_label(scratch)
</code></pre>

<p>And in the report I did:</p>

<pre><code>order by scratch
</code></pre>

<p>But it didn't work......  Any other suggestions ??
Thank you!</p>