Question : Sybase Output to variable filename

Hi There,

I am trying to use the Sybase Output to command to output a query to a text file.  I would like to be able to replace the filename with a variable.

In the end I would like to have filenames of Export20081128.csv, Export 20081129.csv, ect.

Thanks,

Answer : Sybase Output to variable filename

The OUTPUT clause is an ISQL feature, not part of the database server itself.  As such, you cannot use it from a stored procedure or in a SQL block where you declare a variable because ISQL will have no way of resolving the variable to a value in it's own context.

If you want files on the client side of things, you have a couple of choices.  You can script the ISQL commands and execute them or you can use the BCP utility to bulk copy the data out.

If you want the files on the sever, you can use the UNLOAD TABLE command.  This is, unfortunately, kind of heavy handed as it will unload the entire table.  You might create a view and then do the UNLOAD TABLE against the view.  I have not tried it in ASA but it works for BCP in ASE so I suspect it may well work in ASA for UNLOAD TABLE.  Give it a try and let us know if it works.

Regards,
Bill


Random Solutions  
 
programming4us programming4us