Re: Possible to set field separator on command line dbaccess
Posted in 1996
You should consider revising your command to use:
dbaccess dbase - <<EOF
unload to "/tmp/outputfile"
select field1, file2, ... from table where field1 like "foobar%";EOF
You might want to do something with standard output and standard error (you
CAN redirect them from both ISQL and DB-Access, contrary to what was
asserted in a vaguely related discussion at the end of last week and the
beginning of this).
Alternatively, if you have access to dejanews or the IIUG archives, you may
be able to find a tool using awk which, to some degree, handles that for
you. I've not tested it, and since I can't locate it in my mail archive, I
have no better info for you other than it was a year or more ago, and may
have been posted by Dave Cortesi. I use my own sqlcmd (definitely
available via the IIUG archive) for this sort of work.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
PS: Try http://www.iiug.org for the IIUG archive.
}Date: Wed, 26 Jun 1996 17:23:37 -0700 (PDT)
}From: Matt Silveira <msilveir@campus.mci.net>
}X-Informix-List-Id: <list.10512>
}
}I've been battling with this problem and have had no luck!
}
}I am trying to grab a query from the command line and redirect it to a file in the hopes
}that I can delimit the file that dbaccess returns
}
}I have it running on a Sun with Solaris 2.4 and Informix 5.x
}
}The script (not exact model) looks something like this:
}
}>!#/bin/sh
}>#
}>dbaccess databasename << EOF > /tmp/outputfile
}>
}>select field1, field2, from table where field1 like "foobar%"
}>
}>EOF
}
}So, if I run the script above, named "clueless", from the command line like so:
}
}thor% clueless
}
}I get an output file that looks something like this:
}
}(added \\n for clarity)
}
}foobar1 ABC \\n
}foobar12 \\n
}foobar1233 ABC
}foobar12345 DEF
}foobar124556 DEF
}foobar2545 \\n
}foobar23456 \\n
}foobar23677 \\n
}foobar2324 \\n
}foobar22354 \\n
}
}So, the problem (at last) is that I cannot tell when field 2 is null in
}the output without a field separator of some kind because perl and awk
}(yes, hokey but works for this) don't work well without a *consistent*
}separator of somesort. (Splitting on white space in perl would not work
}for this reason)
}
}Any fixes?!?!
}I am in urgent need!
}
}Please write to me or post to the group.
}
}Matt Silveira
}msilveir@campus.mci.net