homefeaturesexamplesDOCUMENTATIONblogpricingcontact us
technical documentationCATI documentationcookbookrobot

Creating an open-end part allowing only unique values


You want to create an open-end part which accepts only values which have not yet been recorded in the same field.


The following Test pound instruction offers this service:

    # Test WhateverName =
      #> [CONDITION]{_nrecords_mysql("project","WHERE ANUMBER=\"$ANUMBER\" AND _telkey<>\"$_telkey\"") != 0}
      #> [MESSAGE][EN]This file number already exists[FR]Ce numéro de dossier existe déjà


Let's say one question requests a file number and that no two cases in the data base can refer to the same file number.

The Test instruction above is triggered by question ANUMBER before any data are recorded in the data base (thereby avoiding duplicate file number data). The trigger condition is key here:

  • the CONDITION is within braces, which indicates that it is in Perl format (rather than in xBase format);
  • the _nrecords_mysql function returns the number of records which correspond to a certain condition in a CallWeb data base;
  • its first argument is the name of the CallWeb project to query;
  • its second argument is the condition to test; here, it tests for the presence of ANUMBER values which are the same as the ANUMBER value just received from the user AND which are from cases other than the current record.


e-mail technical support!