Query in batch files

Discussions about CSEntry
Post Reply
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Query in batch files

Post by prabhustat »

Dear Team,

When I am writing a batch program for load cases from external Dict, I have struck with some queries listed below, any one please suggests.

1. I want to clear the previous loaded cases each time, when I am run the batch program, before loading the cases. What command I have use?

2. How to load last case, when I have situation with same id’s multiple times (occurrence errors is coming).

3. How to split the file with each unique id’s of last cases.


I have enclose the application for reference.

Thanks in advance.

Prabhu
Attachments
MDR_TB_LF.zip
(26.83 KiB) Downloaded 273 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Query in batch files

Post by josh »

You can use the clear() function to remove the previously loaded case. See the help for more details.

You cannot use a a data file that has duplicate cases with an external dictionary. CSPro will not be able to build the index file and will give you an error. You will need to first remove the duplicates either using the Index Files tool or using the data file as the main data file in a batch application.
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Query in batch files

Post by prabhustat »

Thanks Josh, I will try it, my current problem I am facing I want to load the last case,

i.e.in my situation I have id’s of (State Code, District Code, year, month, case id and sessions) the first five id variables can be same only sessions id variable can come multiple times. For example if I have 1,2 and 3 sessions cases I want load the last session (3rd session).

Is it possible load the last cases using max function or some other way, will you please suggest.

Other way is it possible to create separate file of the last cases of each unique id. If you have any example please share it.

Thanks in advance.

Prabhu
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Query in batch files

Post by josh »

If not all id variables are the same then you shouldn't get any duplicate cases error.

You can use locate() followed by loadcase() in a loop to get all the cases matching the first five variables. Then you can pick out the last one.
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Query in batch files

Post by prabhustat »

Thanks Josh..
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Query in batch files

Post by prabhustat »

Thanks Josh, I have tried, but not able to solve, if you have any example will you please share it.

Thanks in advance

Prabhu
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Query in batch files

Post by prabhustat »

Hi Team,

Anyone have example, Thanks,

Prabhu
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Query in batch files

Post by Gregory Martin »

This may not be the most efficient way of doing this, but the code below cycles through every possible ID, from high to low, and tries to find a case that exists. If it finds such a case, then it loads it. This code assumes that ID1 and ID2 are already filled in and then looks for the highest ID3.
numeric caseFound;

numeric id3Ctr;

do id3Ctr = maxvalue(ID3) while ID3 >= minvalue(ID3) by -1

    ID3 = id3Ctr;
    
    
if locate(EXT_DICT_DICT,=,itemlist(ID1,ID2,ID3)) then
        
loadcase(EXT_DICT_DICT);
        caseFound =
1;
        
break;
    
endif;

enddo;

if not caseFound then
    
errmsg("Could not find a case with the specified parameters!");
endif;
prabhustat
Posts: 72
Joined: March 17th, 2012, 10:46 am

Re: Query in batch files

Post by prabhustat »

Thanks Josh
Post Reply