MySQL Forums
Forum List  »  Stored Procedures

prepared 'select into outfile' with delimiters
Posted by: Monica Braverman
Date: July 12, 2011 03:56PM

After much work, I was able to get a stored procedure to work in a prepared statement with a variable output file name for "select into outfile outfilename from tablename." This is a windows install. The code is:

select concat('c:\\\\dvypath\\\\',oid,'.txt ') into @oidpath ;
set @myvar = concat('SELECT * INTO OUTFILE ' ,"'",@oidpath,"'", ' from dvytab') ;
PREPARE stmtvar1 FROM @myvar;
EXECUTE stmtvar1;

oid is a variable that has the file name which comes from an input parameter.

This works well and writes a tab delimited file. The issue is, I need a pipe delimited field, cr/lf terminated file. I have put it into variables and tried every permutation. I have saved the prepared file before execution into a file and then looked at it and it looks perfect. But it errors every time. Simply will not execute. If I take the same statement and run it 'unprepared,' it runs.

Any ideas on how I can get a pipe delimited file in this way?

Thanks. Monica

Options: ReplyQuote


Subject
Views
Written By
Posted
prepared 'select into outfile' with delimiters
3809
July 12, 2011 03:56PM


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.