Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved] Creating Attribute/Value Pairs From Oracle Table.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[Solved] Creating Attribute/Value Pairs From Oracle Table.
 Login/Join
 
Master
posted
Greetings,

I have a requirement to create a file consisting of attribute/value pairs.

My input is an Oracle table.

Currently I am using the IB sample database 'EMPDATA' as my model.

Here is what I have at the moment..

Focexec:
APP PREPENDPATH IBISAMP
FILEDEF FSEQ DISK common/fseq.txt
JOIN CLEAR *
-RUN
-*
JOIN BLANK WITH PIN IN EMPDATA TO BLANK IN FSEQ AS J1
-*
DEFINE FILE EMPDATA
 BLANK/A1 WITH PIN = ' ';
 ATTRIBUTE/A25 = DECODE COUNTER(  1 'LASTNAME'
                                  2 'FIRSTNAME');
 VALUE/A25     = IF COUNTER EQ 1 THEN LASTNAME ELSE FIRSTNAME;
END
-*
TABLE FILE EMPDATA
 PRINT ATTRIBUTE
       VALUE
 IF COUNTER EQ 1 OR 2
 IF LASTNAME EQ VALINO
 ON TABLE SAVE AS SVATTRS
END
-RUN
-SET &WORK = &LINES;
-*
-REPEAT ENDLOOP1 &WORK TIMES
-READ SVATTRS &ATTR.A25. &VAL.A25.
-TYPE Attribute: &ATTR Value: &VAL
-ENDLOOP1
-EXIT


Results:
0 NUMBER OF RECORDS IN TABLE=        2  LINES=      2
 ALPHANUMERIC RECORD NAMED  SVATTRS
 0 FIELDNAME  ALIAS         FORMAT LENGTH
   ATTRIBUTE                A25    25
   VALUE                    A25    25
 TOTAL                             50
 Attribute: LASTNAME  Value: VALINO
 Attribute: FIRSTNAME Value: DANIEL  


The attributes are a subset of the fields in the input file. And the attribute values, are the contents of the field in the file.

I am using the McGuyver technique to do a in memory read the incoming record n number of times.

n is equal to 2 in this case, because I want two attribute/value pairs.

My request: Is there a better way to do this, then what I am doing now?

In my real case I need to create 40 attribute/value pairs (from a very wide Oracle table), and I am concerned about the growing complexity of the IF THEN ELSE structure.

Thanks in advance,
Dave

This message has been edited. Last edited by: David Briars,




Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
 
Posts: 822 | Registered: April 23, 2003Report This Post
Expert
posted Hide Post
How about this.
TABLE FILE SYSCOLUM
PRINT NAME USAGE
WHERE TBNAME EQ 'EMPDATA'
ON TABLE SAVE AS COLNAMES 
END

-RUN

-SET &COLS = &LINES ;

FILEDEF SVATTRS DISK svattrs.ftm

TABLE FILE EMPDATA
 PRINT 
-REPEAT COLLOOP FOR &CNTR FROM 1 TO &COLS ;

-READ COLNAMES NOCLOSE &ColName.A66. &ColFmt.A8.
-SET &ColName = TRUNCATE(&ColName) ;
-SET &ColFmt  = TRUNCATE(&ColFmt) ;

 COMPUTE COL&CNTR/I2 = PUTDDREC('SVATTRS',7,LJUST(&ColName.LENGTH,'&ColName','A25') | FPRINT(&ColName,'&ColFmt','A25') ,50,COL&CNTR) ;

-COLLOOP
 WHERE RECORDLIMIT EQ 1
 ON TABLE HOLD AS WRITEOUT 
END

-RUN

-REPEAT ENDLOOP1 &COLS TIMES
-READ SVATTRS &ATTR.A25. &VAL.A25.
-TYPE Attribute: &ATTR Value: &VAL
-ENDLOOP1


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Master
posted Hide Post
Thank you Waz!

This is the 'quantum leap' improvement to my version, that I was hoping for.

The use SYSCOLUM reduces hardcoding.

Function PUTDDREC nicely stacks the attribute-value pairs.

And FPRINT greatly supports my need to reformat the non-text fields.

Once again, many thanks,
Dave Smiler
 
Posts: 822 | Registered: April 23, 2003Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [Solved] Creating Attribute/Value Pairs From Oracle Table.

Copyright © 1996-2020 Information Builders