SQLplus query to show tag references by reading list of tags from a text file

Download as pdf : 
Products:  
Last Updated: 07-Dec-2022
Versions: 
Article ID: 000100537
Primary Subject: 
Question

Can an Aspen SQLplus query show references to tags by reading a list of tags from a text file?

Answer

Yes!  The following query can be used to show references to tags.  It will get the list of tags from a plain text file referenced inside the query.

Here's an example of the contents of the text file (one tag per line, no punctuation):

ATCAI
Feed
TI4000



Here's the Aspen SQLplus code:

-- This query will look for references to a tag
-- It is *intended* to work with tags but it might work with other definitions

local search record;
local search_for record, found_field field;

for (select line as search_for from 'c:\temp\find_refs.txt') do
     search = cast (search_for as record);
     found_field = nxtrefer(null, search);
     while found_field is not null do
          write 'Found references for tag: '||search||', found in: '||found_field;
          found_field = nxtrefer(found_field, search);
     end;
end;



And here is an example of the corresponding output when the text file listed above is used:

Found references for tag: ATCAI, found in: SCRATCH_CONSOLE_2 DETAIL_DISPLAY_FIELD
Found references for tag: ATCAI, found in: IP_UnackAlarmSummary 31 SUMMARY_LINE
Found references for tag: ATCAI, found in: AspenChem_Get 76 IO_VALUE_RECORD&FLD
Found references for tag: ATCAI, found in: Simulation Tags Folder 1 RECORD_NAME
Found references for tag: ATCAI, found in: ATC007RTC_pap 1 RECORD_&_FIELD_NAME
Found references for tag: ATCAI, found in: KPI1 IP_VALUE_SRC_REF
Found references for tag: ATCAI, found in: -- ALBERS RECORDS -- 2 RECORD_NAME
Found references for tag: Feed, found in: IP_UnackAlarmSummary 65 SUMMARY_LINE
Found references for tag: Feed, found in: AspenRefinry_Get 1 IO_VALUE_RECORD&FLD
Found references for tag: Feed, found in: -- ALBERS RECORDS -- 1 RECORD_NAME
Found references for tag: TI4000, found in: IP_AlarmSummary 76 SUMMARY_LINE
Found references for tag: TI4000, found in: IP_UnackAlarmSummary 75 SUMMARY_LINE
Found references for tag: TI4000, found in: AspenRefinry_Get 2 IO_VALUE_RECORD&FLD



Here are some screenshots of the text file contents, the SQLplus code, and the output:

Screenshot of the text file used by the SQLplus query


Screenshot of the SQLplus code and output in the SQLplus Query Writer