Dynamically access TEMP-TABLE index data

Posted by twc on 03-Nov-2014 12:09

Progress 10.1C and 10.2B

How does one dynamically access index keys of a TEMP-TABLE?

Use Case:

  • Dataset created with no direct DB table relation (i.e. no "like" DB table to access _file, _field, _index to process)
  • Utility processing implemented dynamically - pass any dataset handle with any structure, all character fields are processed and SOME CAN BE changed
  • using tracking-changes and BEFORE-TABLES
  • Utility provides reporting support - any dataset handle received will have changes reported based upon BEFORE-TABLES
  • report data changed by:
  1. find unique index with fewest components (fields) - if no unique key, use primary index (how to do this???)
  2. print index field name/values (i.e. allow user to uniquely identify source data)
  3. for fields changed, display field name and before/after values

Can't find anything about dynamic TEMP-TABLE index access with the one exception - ":primary" displays the name (character value) of the primary index.  The name doesn't help determine which fields are components of the primary index.  What about other indexes?  Seems like this has to be available and I am just missing it.

Thanks,

Tim

Posted by Peter Judge on 03-Nov-2014 12:15

INDEX-INFORMATION() on the temp-table handle? From the help: "
Returns index information in a comma-separated list for the ith index in the buffer’s table.
The returned comma-separated list consists of the following in the specified order:
  The index name
 
  Three integer values of value 0 (FALSE) or 1 (TRUE) depending on whether the index is unique, primary or a word index
 
  The names of the index fields, each followed by a 0 (ascending) or 1 (descending)  "
 
Simple code example:
phIn is a buffer handle.
 
    method protected void WriteIndexInfo(phIn as handle):
        define variable iLoop  as integer   no-undo.
        define variable iMax   as integer   no-undo.
        define variable cIndex as character extent no-undo.       
       
        assign
            iMax           = 1
            cIndex[iMax]   = phIn:index-information(iMax)
            .
        do while cIndex[iMax] ne ?:
            assign
                iMax         = iMax + 1
                cIndex[iMax] = phIn:index-information(iMax).
        end.
    end method.
   
hth,
-- peter
 
 
[collapse]
From: twc [mailto:bounce-twc@community.progress.com]
Sent: Monday, 03 November, 2014 13:10
To: TU.OE.Development@community.progress.com
Subject: [Technical Users - OE Development] Dynamically access TEMP-TABLE index data
 
Thread created by twc

Progress 10.1C and 10.2B

How does one dynamically access index keys of a TEMP-TABLE?

Use Case:

  • Dataset created with no direct DB table relation (i.e. no "like" DB table to access _file, _field, _index to process)
  • Utility processing implemented dynamically - pass any dataset handle with any structure, all character fields are processed and SOME CAN BE changed
  • using tracking-changes and BEFORE-TABLES
  • Utility provides reporting support - any dataset handle received will have changes reported based upon BEFORE-TABLES
  • report data changed by:
  1. find unique index with fewest components (fields) - if no unique key, use primary index (how to do this???)
  2. print index field name/values (i.e. allow user to uniquely identify source data)
  3. for fields changed, display field name and before/after values

Can't find anything about dynamic TEMP-TABLE index access with the one exception - ":primary" displays the name (character value) of the primary index.  The name doesn't help determine which fields are components of the primary index.  What about other indexes?  Seems like this has to be available and I am just missing it.

Thanks,

Tim

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

All Replies

Posted by Peter Judge on 03-Nov-2014 12:15

INDEX-INFORMATION() on the temp-table handle? From the help: "
Returns index information in a comma-separated list for the ith index in the buffer’s table.
The returned comma-separated list consists of the following in the specified order:
  The index name
 
  Three integer values of value 0 (FALSE) or 1 (TRUE) depending on whether the index is unique, primary or a word index
 
  The names of the index fields, each followed by a 0 (ascending) or 1 (descending)  "
 
Simple code example:
phIn is a buffer handle.
 
    method protected void WriteIndexInfo(phIn as handle):
        define variable iLoop  as integer   no-undo.
        define variable iMax   as integer   no-undo.
        define variable cIndex as character extent no-undo.       
       
        assign
            iMax           = 1
            cIndex[iMax]   = phIn:index-information(iMax)
            .
        do while cIndex[iMax] ne ?:
            assign
                iMax         = iMax + 1
                cIndex[iMax] = phIn:index-information(iMax).
        end.
    end method.
   
hth,
-- peter
 
 
[collapse]
From: twc [mailto:bounce-twc@community.progress.com]
Sent: Monday, 03 November, 2014 13:10
To: TU.OE.Development@community.progress.com
Subject: [Technical Users - OE Development] Dynamically access TEMP-TABLE index data
 
Thread created by twc

Progress 10.1C and 10.2B

How does one dynamically access index keys of a TEMP-TABLE?

Use Case:

  • Dataset created with no direct DB table relation (i.e. no "like" DB table to access _file, _field, _index to process)
  • Utility processing implemented dynamically - pass any dataset handle with any structure, all character fields are processed and SOME CAN BE changed
  • using tracking-changes and BEFORE-TABLES
  • Utility provides reporting support - any dataset handle received will have changes reported based upon BEFORE-TABLES
  • report data changed by:
  1. find unique index with fewest components (fields) - if no unique key, use primary index (how to do this???)
  2. print index field name/values (i.e. allow user to uniquely identify source data)
  3. for fields changed, display field name and before/after values

Can't find anything about dynamic TEMP-TABLE index access with the one exception - ":primary" displays the name (character value) of the primary index.  The name doesn't help determine which fields are components of the primary index.  What about other indexes?  Seems like this has to be available and I am just missing it.

Thanks,

Tim

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by twc on 03-Nov-2014 15:58

Thanks Peter - I combed the documentation, including 11.3, but came up empty - was only looking at temp-table object (a bit more intuitive in my opinion).

It certainly would be nicer if there were an index object (wouldn't require parsing to get information), but at least we have something.  Again, thanks.

Posted by Peter Judge on 03-Nov-2014 20:33

Agree on both points. I find that the buffer has most stuff that you need to work with temp-tables (but not all), so I tend to look there first.
 
-- peter
 
[collapse]
From: twc [mailto:bounce-twc@community.progress.com]
Sent: Monday, 03 November, 2014 16:59
To: TU.OE.Development@community.progress.com
Subject: RE: [Technical Users - OE Development] Dynamically access TEMP-TABLE index data
 
Reply by twc

Thanks Peter - I combed the documentation, including 11.3, but came up empty - was only looking at temp-table object (a bit more intuitive in my opinion).

It certainly would be nicer if there were an index object (wouldn't require parsing to get information), but at least we have something.  Again, thanks.

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

This thread is closed