Results 1 to 4 of 4
  1. #1
    Join Date
    May 2008
    Posts
    21

    Outputting query to log file

    IBM Informix Dynamic Server Version 11.70.FC1X3
    Red Hat Enterprise Linux Server release 5.6 (Tikanga)

    This is something that may need to be posted in the shell scripting forum, but being I'm using Informix, I'll start here first.

    I have a shell script and can't figure out how to send the SQL output that's seen on the screen over to a log file.

    I run the shell script and this is what's seen on the screen. How do I get this same output into a log file?

    Database selected.
    1613 row(s) unloaded.
    Database closed.


    Below is my embedded SQL...

    echo "`date` Unloading data to a csv file..." >> $LOGFILE

    dbaccess atb <<ENDSQL

    UNLOAD TO
    '/home/safilo/euclid_elements/output_files/solstice_hourly.$DATE.csv'
    DELIMITER ','

    SELECT * FROM informix.table
    WHERE col_date BETWEEN TODAY - 15 AND TODAY - 2;

    ENDSQL

    echo "`date` Unload complete." >> $LOGFILE

  2. #2
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    346
    Hi salomon,

    how about this:

    Code:
    dbaccess atb 2>$LOGFILE <<ENDSQL
    UNLOAD TO
    '/home/safilo/euclid_elements/output_files/solstice_hourly.$DATE.csv'
    DELIMITER ','
    
    SELECT * FROM informix.table
    WHERE col_date BETWEEN TODAY - 15 AND TODAY - 2;
    
    ENDSQL
    You can even use a perl or awk script to trap the errors and unload rows number,

    or why not write it all in perl, which will be way easier?

  3. #3
    Join Date
    May 2008
    Posts
    21
    Thanks Begooden! That worked perfectly. My perl and awk knowledge is pretty much non-existent, but I'll start looking into both, especially if perl is easier.

  4. #4
    Join Date
    Sep 2011
    Location
    Pont l'Abbé, Brittany, France
    Posts
    346
    Hi,

    take a look at this post, which is a good starter to use Perl with Informix and make you feel like diving into Perl.

    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •