Writing to a file from a Stored Procedure
Posted in 2005
Topics: Stored Procedures & SPL
Hello, We have created a procedure which retrieves some table information. Is it possible to write that information to a text file from the procedure? If yes, please let us know the way to do it. If no, please let us know any workaround. A sample code for the same will be very much helpful. Appreciate your help on this. Thanks and Regards, Vamsi Mohan Harish -- Message posted via http://www.dbmonster.com
Harish Vamsi Mohan via DBMonster.com wrote:
> We have created a procedure which retrieves some table information. Is it
> possible to write that information to a text file from the procedure? If
> yes, please let us know the way to do it. If no, please let us know any
> workaround.
>
> A sample code for the same will be very much helpful.
CREATE PROCEDURE WriteToFile(fn varchar(128), data varchar(255))DEFINE cmd CHAR(512);
LET cmd = "echo '" || trim(data) || "' >" || trim(fn);
SYSTEM cmd;
END PROCEDURE;
Untested - might conceivably work.
--
Jonathan Leffler #include <disclaimer.h>
Email: jleffler@earthlink.net, jleffler@us.ibm.com
Guardian of DBD::Informix v2005.01 -- http://dbi.perl.org/
Or convert the procedure to a 'C' User Defined Function that writes the data to a file