Page 1 of 1

Delete function

Posted: February 1st, 2013, 5:32 pm
by Nevillefc
I am attempting to use the "delete" function to remove records from a data file, however the statement isn't being compiled. The error I get says the "Record, group or multiple item name expected near ". I am certain that I am using the record name for the case in question. I haven't used the delcase function as that leaves the data in the file. This is the code I am using.

do varying i = totocc(survey_access_REC) until i <= 0 by (-1)
if Oper_folder = "DP01" and
oper_code = "201"
then
delete (survey_access_REC(i)); { remove operator's access to survey folder }
endif;
enddo;

where oper_folder and oper_code are id items. I get the error at the delete line in CSPro 4.1 . It passes the total occurances syntax, so the record seems to be valid.

Re: Delete function

Posted: February 1st, 2013, 11:31 pm
by htuser
How and were do you declare i? as numeric or as curocc(); ??

Re: Delete function

Posted: February 3rd, 2013, 7:34 pm
by Nevillefc
i is a numeric and is declared in the proc global. I copied the code from the delete function in the cspro help.

Re: Delete function

Posted: February 4th, 2013, 2:04 pm
by Gregory Martin
The insert/delete functions are tricky. You don't use the record name but instead the "group" name, which you can find by looking at your form tree. It'll be similar to the record name, but with some numbers or letters added after it.

For example, if you are writing a batch application and want to delete SURVEY_ACCESS_REC(i), you would write:
delete(SURVEY_ACCESS_REC_EDT(i));
Or, in data entry it would look something like this:
delete(SURVEY_ACCESS_REC_FORM(i));
or:
delete(SURVEY_ACCESS_REC000(i));

Re: Delete function

Posted: July 20th, 2017, 7:06 am
by Yana
Dear Greg
If there is data that isn't necessary for the main data collection for example training data , and how to declare the delete function , is it from the Records or from the data files?
Thanks in advance

Re: Delete function

Posted: July 25th, 2017, 11:29 am
by Gregory Martin
The delete function is for record occurrences. If you want to delete a case, you need to use the delcase function. However, you can't delete a case from the current file you're entering data into, so usually you use that function in a menu program.

Re: Delete function

Posted: July 29th, 2017, 3:15 pm
by Yana
Dear Gregory
If there is any application based on deleting functions please post it .