Focal Point
[solved]Computed field name same as SQL field name

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7637007616

February 15, 2012, 02:06 PM
HCP
[solved]Computed field name same as SQL field name
My experience with webfocus is somewhat limited. I came across something that I'm not sure is a bug in webfocus or not so I would like to know if anyone has ever experienced this before.

We have a SQL pass through statment with some field values and then we also have the same field value in a compute statement. When the results were printed in the report, they end result was sporadic. After investigating I was able to determine thate the column was displayed twice in the hold file.

Example:

SQL SQLORA PREPARE SQLOUT FOR
select amount, dr_cr_indicator
from table_name
where something = true
END

TABLE FILE SQLOUT
PRINT
COMPUTE AMOUNT/D22.2 = IF DEBIT_CREDIT_INDICATOR EQ 'D' THEN (AMOUNT * -1) ELSE AMOUNT;
END
ON TABLE HOLD AS TRANDET

If you do a Print * for TRANDET, you will see the amount column twice, once without the negative sign and once with the negative sign. I'm guessing that webfocus doesn't like the fact that the computed field has the same name as the field value.

Any thoughts or opinions from anyone are appreciated.

Thanks!

This message has been edited. Last edited by: HCP,


Webfocus 7.7.2
Windows, HTML, PDF, and Excel
February 15, 2012, 02:59 PM
njsden
I would not treat that as a bug in WebFOCUS. It is *your code* which is creating new fields with the same name as those in the original source.

By default, WebFOCUS will propagate any field "used" in a request (regardless of whether or not it is being printed) to the HOLD file.

That means that the TRANDET HOLD file should have the following fields in it:

- AMOUNT (the one from the DB used in the COMPUTE expression)
- DEBIT_CREDIT_INDICATOR (also used in the COMPUTE expression)
- AMOUNT (you're computed one).

Even though they have the same name, each has a different alias (E01, E02, etc.) so you could pick the one you need using the alias name.

However, if you require not to have the original AMOUNT field in the HOLD, you can influence how WebFOCUS will do that by:

SET HOLDLIST = PRINTONLY


That way, only the compute'd AMOUNT will be in the HOLD file, because it is the only field that would show up in a report if you commented out the ON TABLE HOLD line in the request!

That's actually one of the default settings in my reporting environment but that's because of personal preference.

This message has been edited. Last edited by: njsden,



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 15, 2012, 03:01 PM
Waz
The PRINT * will print all fields in the SQLOUT hold file.

You have created another field called the same name, its as simple as that.

If you don't want the duplicate names, then specify the fields you need, or change the COMPUTE column name.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

February 15, 2012, 03:02 PM
Tom Flynn
Whenever you have a COMPUTE, a row-based value, those columns within the COMPUTE will be included in the HOLD file. The same goes for CNT., CNT.DST., MAX., etc...
Additionally, COMPUTE is most often utilized with SUM; if you are going to PRINT, put it in a DEFINE...


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
February 16, 2012, 06:32 AM
HCP
Thanks for your replies. I figured it was related to duplicate field names and not a bug. I learn a little more every day!

Thanks again...


Webfocus 7.7.2
Windows, HTML, PDF, and Excel
February 16, 2012, 09:34 AM
EricH
Try adding this to your TABLE FILE:

ON TABLE SET HOLDLIST PRINTONLY

EricH
February 19, 2012, 04:21 PM
HCP
Thanks for all the replies. I tested the ON TABLE SET HOLDLIST PRINTONLY and that took care of the duplicate fields.


Webfocus 7.7.2
Windows, HTML, PDF, and Excel