Question How can I control usage of fieldlist <FIELDS>

Venkateswarlu N

New Member
We started following a new coding standard to improve performance (version 10.2B).

That is to use FIELDS to only retrieve only the necessary fields, this has very good results. But I am worried of run time errors when using fields that aren't in the list (compiler doesn't warn of these).

I tried to do something on ProLint but didn't get anywhere as I am new to it.

Any help and updates please:)

Thanks,
Venky
 
It gives a Compiler error in the 11.3. I have worked on 10.2b around 5 years ago, I do not remember this happening. Are you working with temp-tables?
 

TheMadDBA

Active Member
As far as I know there are no compiler messages for missing fields list columns. Including 11.3.1.

Code:
FOR FIRST customer FIELDS(cust-num NAME) NO-LOCK:
    DISP customer.country.
    DISP customer WITH 1 COL NO-BOX.
END.

This returns runtime errors with no compiler issues for 10.2B and 11.3.

The best you can do is to test thoroughly before releasing code and try and write some code to parse a listing and XREF to try and match the two up.

1) Compile your code with the preprocess option (to flatten out the line numbers and merge includes/etc).
2) Compile the preprocess output with XREF to get the list of columns
3) Write some code to parse the preprocess and XREF and try and match up the columns based on line number ranges.
 

TheMadDBA

Active Member
There is a difference between an invalid field name (which will throw a compiler error like above) and a missing field from the fields list expression. The fields list is used to limit network traffic by only pulling certain fields back from the database. The default is to pull the entire table back.
 

Venkateswarlu N

New Member
Thanks @TheMadDBA

This is what I was trying to do using a ProLint rule.

Could you please help me learn more about your steps

1) Compile your code with the preprocess option (to flatten out the line numbers and merge includes/etc).
2) Compile the preprocess output with XREF to get the list of columns
3) Write some code to parse the preprocess and XREF and try and match up the columns based on line number ranges.
 

Cringer

ProgressTalk.com Moderator
Staff member
There is a session startup parameter in 11.x (maybe also 10.2B08) that refetches a record if the fields phrase is invalid. It results in 2 reads of the record if the FIELDS fails though, so should only be turned on in production.
Oh I've just found the details and it was introduced in 10.2B07
Note: OE00217697 Type: Behavior Change
New startup parameter causes AVM to re-read records with missing FIELDS
---------------------------------
If a query with a field list (FIELDS or EXCEPT option of the record phrase)
reads a partial record, and a field is subsequently referenced that is not in
the field list, the AVM normally raises a runtime error (8826). With the
-rereadfields startup parameter, the AVM instead suppresses this error and
re-reads the full record from the database.
 

Venkateswarlu N

New Member
Thanks @Cringer -rereadfileds works for me :) v10.2b07.

However I am asked to write a rule on prolint, is it possible?

This is my first rule, so any help how to start. I did look at existing rules, can understand them partly but not enough to decyphier the syntax.
 

TheMadDBA

Active Member
Nice Cringer... that parameter slipped by without me noticing it.

I have made a few simple Prolint rules in the past but nothing so complex. I am sure it can be done but you will need more of an expert I suspect. OE Hive is a good place to start like the good doctor suggests.
 
Top