1

When I try to save the result of several queries in a file with an unload command in Dbaccess environment , only the first one is saved, and if I use unload several times -one time per query-, only the last query result is saved.

unload to file1

select * from table1;
select * from table2;
select * from table3;

Can anyone help?

MD128
  • 501
  • 4
  • 12
  • As far as I know, UNLOAD can't append data to an file, it will always create it, so unload to individual files and then join them all together. If all the tables have the same number and type of columns you can use a UNION ALL to join all the SQL statements into one. (if not, I'm not quite sure what you would achieve with the resulting unload file) – jsagrera Sep 08 '20 at 13:50
  • @jsagrera : unfortunately the union didn't work in the case "select sum(1) as sum_t1 from table 1 ; select sum(1) as sum_t2 from table 2;...) – MD128 Sep 08 '20 at 15:51
  • 1
    If the format from [OUTPUT](https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.sqls.doc/ids_sqs_0926.htm) is usable to you, you can use `OUTPUT TO "file1" SELECT * FROM table1; OUTPUT TO PIPE "tee -a file1" SELECT * FROM table2; OUTPUT TO PIPE "tee -a file1" SELECT * FROM table3;` — assuming a sufficiently Unix-like system with the `tee` command. You might need the `WITHOUT HEADINGS` clause. – Jonathan Leffler Sep 09 '20 at 02:57
  • @jsagrera :it is working,t_h_a_n_k_s, but could i find it in informix document or linux doc? – MD128 Sep 09 '20 at 04:43
  • UNLOAD expects a single SQL statement. See the following links (https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.sqls.doc/ids_sqs_1248.htm) and (https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.sqlt.doc/ids_sqt_192.htm) for the UNLOAD and UNION commands. – jsagrera Sep 09 '20 at 08:08

0 Answers0