On Feb 29, 2012, at 10:43 AM, Ed Patterson wrote:
> Be kind, I am by no means any type of DB expert.
> I would like to eventually move this to a stored procedure but for now I am using the
> \. to fire it off.
> Here is what I have so far (generating a list of machines missing software)
> select last_logon.host_name_short
> from last_logon
> left join mcafee on last_logon.host_name_short = last_logon.host_name_short
> where mcafee.host_name_short is null
> and last_logon.host_name_short like 'w%'
> -- the above works
> into outfile (select concat('Missing-',date_format(now(),'%Y%m%d%H%i'),'txt');
> -- this line breaks it
> The select concat() works from the command line
> I can manually add the file name but would like to automate the process
> Lastly, if it makes a difference, I don't use any graphical tools for DB stuff.
> Inevitably someone says 'click here' :-)
> Thanks for any help
-- create statement, assign to user variable
set @s = concat('
left join mcafee on last_logon.host_name_short = last_logon.host_name_short
where mcafee.host_name_short is null
and last_logon.host_name_short like \'w%\'
into outfile \'Missing-',date_format(now(),'%Y%m%d%H%i'),'.txt\'');
-- display so you can verify what it looks like
-- prepare statement, execute it, discard it
prepare s from @s;
deallocate prepare s;
Note: I added a '.' before 'txt' and a closing quote to the file name.
Oracle Corporation / MySQL Documentation Team
Madison, Wisconsin, USA