> > Can somebody help me with the syntax of EVAL.  I want to execute a 
> > SELECT on a file to get all records where (field 16)*0.9 < 
> field(17).
> 
> Various ways to do this.  Try...
>    SELECT file WITH EVAL "F16 * 0.9 < F17" = 1
> where F16 and F17 are field names from the dictionary.
> 
> The most common mistake is to miss off the = 1 at the end.  
> Remember, this EVAL expression is going to return true or false.


1. Yes, but put quotes around the final literal 1:

     WITH EVAL "F16 * 0.9 < F17" = "1"

or it will try to find a record called "1" in both the dictionary and
VOC.  Many Pick-style dicts have that.  Even if it doesn't exist today,
it might in the future.


2. You might be tempted to do:

     WITH EVAL "F16 * 0.9" < F17
 (or WHEN  ''    ''    ''     ''   for multivalued data)

which will probably work, but with EVALs you sometimes need to include
explicit formatting & conversion on the command line.   RetrieVe
sometimes outsmarts itself when sorting BY an EVAL or using an EVAL as a
display column.  By default it sometimes assigns to the EVAL the
conversion & justification of an element inside the EVAL.   Annoying,
that.   All this makes Martin's answer better, since it is more
explicit.


3. If you use Pick-style dictionaries,  you can still use EVALs, and you
can extract the fields you want:

     WITH EVAL "@RECORD<16> * 0.9 < @RECORD<17>" = "1"


4. All this assumes single-valued fields, right?  Let us know, because
if either F16 or F17 are multi-valued,  you'll need a variation on the
theme by using "LTS" function and/or the WHEN keyword.  


Chas. Stevenson
--
u2-users mailing list
[EMAIL PROTECTED]
http://www.oliver.com/mailman/listinfo/u2-users

Reply via email to