Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are probably aware you can declare <code>DELIMITER "|"</code> in the SQL or via the DBDELIMITER environment variable. As far as I know, there is no way to change the default <strong>record</strong> terminator from <code>NEWLINE</code> to anything else.</p> <p>So I suspect you will need to either write a custom function that iterates through the results and appends them to a variable which you then write out to a file, or write a separate piece of script that you call via <code>RUN</code> that pivots the data from rows to columns, eg:</p> <pre><code>UNLOAD TO file.unl SELECT col FROM table WHERE ...; RUN "/usr/bin/perl -ni -e 'chomp; print' file.unl"; </code></pre> <p>I've assumed you're running on Unix and have perl handy. If you don't, you might find the iterator suggestion more practical than mucking about with installing perl on Windows, particularly if you have limited control over machines this code gets run on.</p> <p><strong>Update</strong></p> <p>My 4GL is very rusty, but I was decribing something very basic, eg:</p> <pre><code>DEFINE command CHAR(10100) DEFINE long_string CHAR(10000) DECLARE curs1 CURSOR FOR SELECT col FROM table WHERE ... FOREACH curs1 INTO col1 LET long_string = long_string CLIPPED || col1 CLIPPED || '|' END FOREACH LET command = "echo '" || long_string CLIPPED || "' &gt; file.unl" RUN command </code></pre> <p>It's 15 years or more since I wrote any 4GL, so treat that as pseudo-code at most, please. There might be a better way to write directly to a file, I honestly can't remember.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload