MySQL Forums
Forum List  »  InnoDB

Two queries, one outfile
Posted by: Stephen Barton
Date: April 04, 2008 04:01AM

Hello,

I need to create a log file which has like a header, which is a single row result from a query. Directly underneath will be a delimited resultset of anything up to 1000 rows. e.g:

header;stuff;here;
data;data;data;data;data;data;data;data;
data;data;data;data;data;data;data;data;
data;data;data;data;data;data;data;data;
data;data;data;data;data;data;data;data;
...etc

I can output both as individual queries using SELECT...INTO OUTFLE, but is there any way to combine the two? I have read that it is not possible, so I have tried other things....

I have created two strings, one for the header and one for the main query. I can populate both OK (using a cursor to help populate the resultset string), but I cannot get the carriage return to work and I get only little rectangles instead of carriage returns when I open the file in notepad.

The strings are defined like:
SET a = CONCAT('header',';','stuff',';','here',';\r');

In Word Pad it looks better:

header;stuff;here;
data;data;data;data;data;data;data;data;
data;data;data;data;data;data;data;data;
data;data;data;data;data;data;data;data;
data;data;data;data;data;data;data;data;

There seems to be a tab before the data..... how do I get the data output to be exactly as I need, no tab, and looks like my example in Notepad. This file is going to be read by a third party system and has to be precise (so I am told).

I have spent a considerable time on this problem, but I hope there is someone out there has a solution.

Many Thanks,
Stephen

Options: ReplyQuote


Subject
Views
Written By
Posted
Two queries, one outfile
3516
April 04, 2008 04:01AM
2191
April 05, 2008 10:11AM
1975
April 23, 2008 02:03AM
1962
April 23, 2008 06:25AM


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.