MySQL Forums
Forum List  »  General

SELECT .. INTO OUTFILE not possible with stored procedure parameters?
Posted by: Klas Karlsson
Date: May 18, 2006 09:13AM

I am trying to d oa stored procedure, where i want to export data in a csv format to a file with a file name which I send into the procedure, like this:

drop procedure exportJob;
delimiter $
create procedure exportJob (IN file_name char(64), IN time_period int, OUT error_msg char(64))
SELECT r.sess,r.orig,r.dest
FROM CDREntry as r, LEntry as le
AND TIME_TO_SEC(NOW()) - TIME_TO_SEC(le.timeStamp) < time_period;

end $
delimiter ;

The problem is that it dioes not work with file_name as a file name.
I have also tried to declare another VARCHAR and CHAR variable, as well as using user defined $var variables, but that doesnt work either. The only export that seems to work is if I hard code the name - but that sort of negates the whole purpose with my stored procedure.

Does anyone know how to get dynamic file names to work with SELECT ... INTO OUTFILE ?
Is it even possible ?

By the way: I will add more logic to the procedure later, otherwise i could run the select without it of course :)

Best regards

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.