Question
· Sep 21, 2021

Terminal script SQL result buffer write size

I am writing a report for a client that will create a report of the current process with a format that mimicks the Management Portal process display. I am writing a cterm script file to generate the report.

In the loop that process the results I am writing the columns in a formatted manner that will result in a CSV format very similar in content and order the process page. However, it appears that the write statement is limited in size such that I can not write out all of the elements of the sys.process query. My query result processing that works correctly is of this format:

send: WHILE rset.%Next() { set sub=$PIECE(rset.%Get("CurrentDevice"),"|",2) set devLen=$LENGTH(rset.%Get("CurrentDevice"),"|") set port=$PIECE(rset.%Get("CurrentDevice"),"|",3) set dev=rset.%Get("CurrentDevice") set IP=rset.%Get("ClientIPAddress") Write rset.%Get("jobNumber"),",", rset.%Get("Pid"),",",rset.%Get("UserName"),",",$CASE( devLen,1:"null",3:dev,4:"|"_sub_"|"_IP_"|"_port),",",rset.%Get("NameSpace"),",",rset.%Get("Routine"),",",rset.%Get("CommandsExecuted"),",",rset.%Get("GlobalReferences"),!}<CR>

But if I add one additional column such as below the query fails:

send: WHILE rset.%Next() { set sub=$PIECE(rset.%Get("CurrentDevice"),"|",2) set devLen=$LENGTH(rset.%Get("CurrentDevice"),"|") set port=$PIECE(rset.%Get("CurrentDevice"),"|",3) set dev=rset.%Get("CurrentDevice") set IP=rset.%Get("ClientIPAddress") Write rset.%Get("jobNumber"),",", rset.%Get("Pid"),",",rset.%Get("UserName"),",",$CASE( devLen,1:"null",3:dev,4:"|"_sub_"|"_IP_"|"_port),",",rset.%Get("NameSpace"),",",rset.%Get("Routine"),",",rset.%Get("CommandsExecuted"),",",rset.%Get("GlobalReferences"),",",rset.%Get("State"),!}

 

Also if I use the command send: do rset.%Display() all of the data is displayed

But I would like to keep the formatted write to better construct the report.

Product version: Caché 2018.1
Discussion (4)1
Log in or sign up to continue

SOLVED

The fix is to break the write statement into multiple 'send:' statements with the last send containing the trailing <CR>. So my write statement becomes:

send: WHILE rset.%Next() { set sub=$PIECE(rset.%Get("CurrentDevice"),"|",2) set devLen=$LENGTH(rset.%Get("CurrentDevice"),"|") set port=$PIECE(rset.%Get("CurrentDevice"),"|",3) set dev=rset.%Get("CurrentDevice") set IP=rset.%Get("ClientIPAddress") Write rset.%Get("jobNumber"),",", rset.%Get("Pid"),",",rset.%Get("UserName"),",",$CASE( devLen,1:"null",3:dev,4:"|"_sub_"|"_IP_"|"_port),",",rset.%Get("NameSpace"),",",rset.%Get("Routine"),",",rset.%Get("CommandsExecuted"),",",rset.%Get("GlobalReferences"),",",

send: rset.%Get("State"),!} <CR>