sp output to text file help
Posted in 1999
Topics: Migration, Import/Export & Data Conversion
I have been asked to setup a shell script that will run about 10 sp's and
save the output to a delimited text file.
I am not sure if I can do something like the following:
unload to 'a.txt' sp_sample_proc
Does anyone have any suggestions?
Michael Talbot wrote:
> I have been asked to setup a shell script that will run
> about 10 sp's and save the output to a delimited text file.
>
> I am not sure if I can do something like the following:
>
> unload to 'a.txt' sp_sample_proc>
> Does anyone have any suggestions?
This was discussed a week or two ago.
No, you cannot at the moment do an UNLOAD using a stored procedure
as the data generator instead of a SELECT statement. This is an
interesting oversight (it has been missing from the product for about
9 years, but has only arisen as a question in the last month; I wonder
what that is telling us about technology transfer rates?).
So, at the moment, you'd have to arrange for the stored procedures
to be select their data into a temp table and then UNLOAD those temp
tables. That too is probably non-trivial; AFAIK, you cannot do:
INSERT INTO temp_table EXECUTE PROCEDURE sp_sample_proc();Nor can you do:
EXECUTE PROCEDURE sp_sample_proc() INTO TEMP temp_table;(One reason for this is that there are no names for the returned
values, so the columns in the temp table wouldn't have names, but
that's a whole separate discussion.)
So, you're likely to have to write some ESQL/C, or adapt some
ESQL/C (eg the sample code from the ESQL/C manuals, or the SQLCMD
program from the IIUG archives). I intend to add the UNLOAD facility
to SQLCMD at some point.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>