I'm trying to execute a query in Caché and output the results to a file on a Unix server, but I'm having trouble finding the right commands.
I tried the following:
%SYS>s rs=##Class(%ResultSet).%New()
%SYS>s rs.ClassName="%SYS.Namespace"
%SYS>s rs.QueryName="List"
%SYS>s sc=rs.Prepare(rs.QueryName)
%SYS>s sc=rs.Execute()
%SYS>s fs=##Class(%IO.FileStream).%New()
%SYS>d fs.Open("/myDir/outputDir/test_filestream.txt")
%SYS>while rs.Next(){d fs.Write(rs.Nsp)}
%SYS>d fs.Close()
%SYS>s sc=rs.Close()
I didn't get any errors when I ran the above, but I also didn't get any output. I would like to have the file created if it doesn't already exist or overwrite it if it does. Is that possible with Caché commands or is server scripting the only way to accomplish this?
I'm having to do this all from the command line on the server so if easier functionality exists using a Caché utility like Caché Studio or Terminal, I don't have that luxury.
Thanks.