Table unload in ESQLC
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Migration, Import/Export & Data Conversion
This is a multi-part message in MIME format. ------=_NextPart_000_0097_01BEEAF5.65C2B9A0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi All, I have a requirement in my program, where I need to unload a temp table = into a .txt file. The UNLOAD command will not work. Is there any other = way of doing this? Thanks in advance. George georgem@its.soft.net ------=_NextPart_000_0097_01BEEAF5.65C2B9A0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2014.210" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2>Hi All,</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>I have a requirement in my program, = where I need to=20 unload a temp table into a .txt file. The UNLOAD command will not work. = Is there=20 any other way of doing this?</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks in advance.</FONT></DIV> <DIV><FONT face=3DArial size=3D2>George <A=20 href=3D"mailto:georgem@its.soft.net">georgem@its.soft.net</A></FONT></DIV= ></BODY></HTML> ------=_NextPart_000_0097_01BEEAF5.65C2B9A0--
george wrote: > I have a requirement in my program, where I need to unload a temp > table into a .txt file. The UNLOAD command will not work. Is there > any other way of doing this? Check out SQLCMD from the IIUG web site. Or the unload example from the ESQL/C documentation, though you should be aware that (when I last looked at it) it is incomplete in that it does not handle all data types. Or use DB-Access. -- Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net) Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN #include <disclaimer.h>
In article <7pio98$jd6$1@news.xmission.com>,
"george" <georgem@its.soft.net> wrote:
>
> This is a multi-part message in MIME format.
Er, George me laddie, d'ya think maybe y'can post messages w'out the
MIME stuff? 'Tis a might awkwarrd rreadin it this way. ;-)
> Hi All,
>
> I have a requirement in my program, where I need to unload a temp
> table into a .txt file. The UNLOAD command will not work. Is there
> any other way of doing this?
George,
I conjecture that you are using ESQL/C to do this.
There is a basic misunderstanding about the UNLOAD command among
newbies. I discovered this years ago when I tried to run an UNLOAD
command in a stored procedure. You discovered it this way.
UNLOAD is a utility command that Informix has been nice enough to
include in dbaccess and isql. It is also availabe as a 4GL statement.
But UNLOAD is *NOT* (!!!) and SQL command; it is simply an extra
utility. Thus while you can issue an UNLOAD command in 4GL, you cannot
PREPARE a statement containing an UNLOAD command. The SQL parser in
the engin will spit it right out as a syntax error. And ESQL/C does
not provide the command, as far as I recall in 7.1.
Your alternatives are:
- Use a dbaccess script to perform the unload command you need.
This is fine if you know the exact query and all the values in
the WHERE clause.
- Use Jonathan's SQLCMD program, as he has already suggested. If I
recall correctly, it has somewhat more flexibility than dbaccess
in this type of query.
- If the query to unload is dynamic - changes by the whim of a user,
you might use isql to get data from the users and teach them to
output in unload format. (That is some time after you teach them
how to turn on the machine. >:)
- If the query to unload is dynamic and the query is really complex
(subqueries, outer joins etc.) you might write a 4GL program to
present a query screen and, after the Query-By-Example is complete,
piece together the SQL statement as if you will PREPARE it. Instead,
however, just keep it in the variable and issue the command:
UNLOAD TO <file name variable> [DELIMITER "|"] sqlstring
- If you insist on ESQL/C, you'd have to write is all yourself - the
formatting, the delimeter, escaping (\\) any delimiters you find in
some of the character data. This is reasonable only if you are a
hopeless masochist.
Main bottom line: ESQL/C is not the tool for the job.
+---- Jacob Salomon - DBA JSalomon@bn.com - ---------------------------+
|--------------- Obligatory sesquipedalian obfuscation: ---------------|
| An object of igneous, sedimentary or metamorphic mineral in combined |
| states of elevated linear and rotational kinetic energy acquires no |
| accumulation of bryophytic vegetation. |
+----------------------------------------------------------------------+
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
Related threads
- Conversion to differeent characters sets
- Problem in changing locale via dbexport/dbimport
- RE: openlink error "Unable to load locale categories"