Focal Point
[CLOSED]Convert column from TEXT to Alpha?

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

February 03, 2012, 11:08 AM
Rodney Chan
[CLOSED]Convert column from TEXT to Alpha?
Not sure if this is feasible but I have a report where one of the columns is set to text with some numbers in it.

So

1
6
8
Full
9
Full

I have some formatting where it checks to see if there is a value in this column 'GE 8'

Im hitting an error saying it cant do it (makes sense) since its a text type field. I also of course cant perform max, min or average for this column since its text.

I was wondering, if i were to convert this column into an ALPHA format would I then be able to manipulate the numbers in the column?

Thanks in advance WF gurus

This message has been edited. Last edited by: Rodney Chan,


WebFOCUS 7.6
Windows, All Outputs
February 03, 2012, 12:28 PM
njsden
How big can your data be in that particular field?

If its around <= 4096 characters, you can just add a new field in your masterfile aliasing the same database field. Make it an "A4096
" data type and treat it as you would any alphanumeric field.



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 03, 2012, 12:36 PM
njsden
This is what I mean ...

Let's say you have a field like the following in your master file:

...
FIELDNAME=MYTEXT, ALIAS=MYTEXT, USAGE=TX50, ACTUAL=TX, $



Adding a new field (still aliasing your MYTEXT database field) you would end up with something like:

...
FIELDNAME=MYTEXT, ALIAS=MYTEXT, USAGE=TX50, ACTUAL=TX, $
FIELDNAME=MYTEXT_ALPHA, ALIAS=MYTEXT, USAGE=A4096, ACTUAL=A4096, $



You can now use MYTEXT_ALPHA as you would with any regular alpha field.

That does not solve your problem about the "8" value. Does the original field contain only "8" as its entire value, or is "8" just one piece among many others that make up the value of that field in a particular record? I ask because TEXT fields by nature are "huge" fields (CLOB's) with any content in them (including LF/CR, etc.) so you may still need to parse this alpha field, extract the value somehow (you know your data patterns) and then use/compare as you need.



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 03, 2012, 05:35 PM
Mary Watermann
From the Manual:

quote:

Using Text Fields in DEFINE and COMPUTE
Text fields can be assigned to alphanumeric fields and receive assignment from alphanumeric
fields. If an alphanumeric field is assigned the value of a text field that is too long for the
alphanumeric field, the value is truncated before being assigned to the alphanumeric field.



WF 7.6.10, Windows, PDF, Excel
February 06, 2012, 08:51 AM
Doug
FIELDNAME=MYTEXT, ALIAS=MYTEXT, USAGE=TX50, ACTUAL=TX, $
FIELDNAME=MYTEXT_ALPHA, ALIAS=MYTEXT, USAGE=A4096, ACTUAL=A4096, $


Just my thoughts here (imho), aside from your original post. You shouldn't use the same value for ALIAS multiple
times. This may cause problems now or later, for you or who ever maintains this code. Also, keep in mind the rules for "shortest unique truncations" when names fields and aliases in MFDs.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
February 06, 2012, 09:24 AM
Wep5622
quote:
I was wondering, if i were to convert this column into an ALPHA format would I then be able to manipulate the numbers in the column?


No, you would need a numeric field for that, not an ALPHA field.

Make sure you have some idea what 'Full' (and possibly other text strings) would mean in a numeric context - is that similar to MISSING or is it perhaps closer to 'infinity'?


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
February 06, 2012, 10:34 AM
njsden
Doug, ALIAS= refers to the physical name of the column in the database, so it can't be changed.

I had a similar confusion years ago when I thought FIELDNAME= referred to the physical field and ALIAS= was just "my" chosen name for the field in the WebFOCUS world but it's actually the opposite. The attribute naming used in the MFD makes this confusing but there's not much we can do about that. Frowner



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 06, 2012, 10:38 AM
njsden
Hmmm, now I am confused again Confused will have to check the docs once more ...



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 06, 2012, 10:53 AM
njsden
Okay, found it!

quote:
Assign a value to ALIAS in the following way for the following types of data sources:

Relational data sources. ALIAS describes the field original column name as defined
in the relational table

Sequential data sources. ALIAS describes a synonym, or alternative name, that you
can use in a request to identify the field. You can assign any name as the alias .. (more stuff)

FOCUS data sources. ALIAS describes a synonym, or alternative name, that you can
use in a request to identify the field ... ( more stuff)



So, ALIAS is indeed a field "alias" when dealing with FOCUS or sequential data sources, but it refers to the original column name in the database (Oracle, SQL Server, etc.) which is the way I regularly use it.

I just assumed Rodney was using a DBMS as he needed to deal with a TEXT field which I usually associate with DBMS-based tables.

Perhaps he could tell us exactly what he's using and how?

Anyway, this was a good refresh of foundation concepts for me Smiler



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 06, 2012, 03:28 PM
Rodney Chan
quote:
Originally posted by Wep5622:
quote:
I was wondering, if i were to convert this column into an ALPHA format would I then be able to manipulate the numbers in the column?


No, you would need a numeric field for that, not an ALPHA field.

Make sure you have some idea what 'Full' (and possibly other text strings) would mean in a numeric context - is that similar to MISSING or is it perhaps closer to 'infinity'?


Ugh this is what i was wanting to confirm.

I will speak to the end user and just try to convince them to use a numeric error code (such as 9999) rather then display text as its really causing a lot of problems with formatting and calculations and such.

Thank you all! (And thanks again njsden ^_^)


WebFOCUS 7.6
Windows, All Outputs