Suggestions please

Hi Everyone,
May be if I explain it in detail someone can suggest something. This involves Oracle Label Security tables.
I’m taking the results from a PL/SQL table which is a single column one dimensional array and using those results as variables to look up a long name for it. As an example
The first row of LABEL_TABLE(v_rows) = S
It is used as a variable to look up in the LBACSYS.SA$LEVELS table the long name, in this case SECRET. The same procedure is used for GROUP and COMPARTMENT too.
I provided some actual output to help visualize.
DESCRIPTION OF PROCEDURE:
This Procedure is to insert the long name and where appropriate also insert the colon and commas. The last value at the end of the string will not have a comma or colon.
TEST DATA:
The only 4 situations that can be produced are the following:
1.     execute sys.ps_LN11('s'); Level only returned.
2.     execute sys.ps_LN11('s:a,d,s_2'); Level and Compartment only returned.
3.     execute sys.ps_LN11('s:a,d,s_2:usa,b,s'); Level, Compartment and Group returnd
4.     execute sys.ps_LN11('R:usa,b,s'); Level and Group only returned.
There can never be a compartment or group returned without a level component.
Test data #’s 1,2,4 all work out fine returning the right values.
1.     SECRET
2.     SECRET: ALPHA, DELTA, SAM_2
4.     RESTRICTED: UNITED STATES, GREAT BRITIAN, SPAIN
Test data # 3 on the other hand returns the following:
SECRET: ALPHA, DELTA, SAM_2, UNITED STATES, GREAT BRITIAN, SPAIN
The comma located between SAM_2 and the UNITED STATES should be a colon :.
This is my problem and am unable to solve it. I cannot seem to be able to identify a variable that will tell me when I have come to the end to then make the change. I hope by presenting my procedure that someone would be able to make a suggestion or two to help resolve this shortcoming.
Here it is in full.
CREATE OR REPLACE PROCEDURE PS_LN11 ( string_in IN varchar2)
IS
label_table sys.ps.atoms_tabtype;
label_total number := 0;
-- delimiters declared in header.
level_string varchar2(15);
comp_string varchar2(15);
group_string varchar2(15);
total_rows     BINARY_INTEGER ;
v_rows      BINARY_INTEGER :=0;
banner           varchar2(500);
/*      This procedure takes a string that has been parsed into it's individual atomics and finds
     the long name in the system table of which there are 3. The long names of each are returned
     in one string with the appropriate separators added.
BEGIN
     ps.parse_string(string_in, label_table, label_total, ': ,' );
     ps.display_atomics(label_table, label_total);
     total_rows := label_table.COUNT;
     DBMS_OUTPUT.PUT_LINE (total_rows);
     v_rows := v_rows + 1;
/*     Now loop through the lable_table sequentially, identify the component as either a "Level",
     "Compartment" or/and "Group". Remember the compartment is optional and may not exist at
     the same time the group can. Convert the short name to the long name. You find the answer in the system tables.
     BEGIN
     --LEVEL COMPONENT.
               SELECT NAME into level_string                
               FROM LBACSYS.SA$LEVELS
               WHERE CODE = UPPER(LABEL_TABLE(V_ROWS));
               IF label_table.COUNT = 1
               THEN
                    banner := level_string;
                    DBMS_OUTPUT.PUT_LINE(level_string);
               ELSIF label_table.COUNT > 1
               THEN
                    banner := level_string||':';
                    DBMS_OUTPUT.PUT_LINE(banner);
               END IF;
     EXCEPTION
          WHEN NO_DATA_FOUND THEN NULL;
     END;
     --COMPARTMENT COMPONENT.  This section is the problem child.
-- I can’t identify what I need to test for to insert the colon between the
     --compartment and group.
     BEGIN          
          WHILE v_rows <= label_total
          LOOP                    
                         v_rows := v_rows + 1;
                         SELECT NAME INTO comp_string
                         FROM lbacsys.sa$compartments
                         WHERE CODE = UPPER(label_table(v_rows));
                         banner := banner||' '||comp_string||',';
                         DBMS_OUTPUT.PUT_LINE(banner);
          END LOOP;
     EXCEPTION
          WHEN NO_DATA_FOUND THEN NULL;
     END;     
     --GROUP COMPONENT.
     BEGIN
          WHILE v_rows <= label_table.COUNT
          LOOP
               SELECT NAME into group_string
               FROM LBACSYS.SA$GROUPS
               WHERE CODE = UPPER(label_table(v_rows));
               V_rows := v_rows + 1;
               banner := banner||' '||group_string||',';
          END LOOP;
     EXCEPTION
          WHEN NO_DATA_FOUND THEN NULL;
     END;
     BEGIN               --This strips the comma from the end of string
                         --for Level: Compartment
-- Level: Group      
          banner := RTRIM(banner,',');
     DBMS_OUTPUT.PUT_LINE(banner);
     END;
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END;
Here is some actual output:
SAMPLE OUTPUT:
SQL> execute sys.ps_LN11('s'); Level only
s
1
SECRET
SECRET
PL/SQL procedure successfully completed.
SQL>
SQL> execute sys.ps_LN11('s:a,d,s_2'); Level: Compartment
s
a
d
s_2
4
SECRET:
SECRET: ALPHA,
SECRET: ALPHA, DELTA,
SECRET: ALPHA, DELTA, SIGMA_2,
SECRET: ALPHA, DELTA, SIGMA_2
PL/SQL procedure successfully completed.
SQL>
(PROBLEM RESULT the comma located between the SIGMA_2 and UNITED STATES should be a colon.)
SQL> execute sys.ps_LN11('s:a,d,s_2:usa,b,s'); Level: Compartment: Group
s                              
a
d
s_2
usa
b
s
7
SECRET:
SECRET: ALPHA,
SECRET: ALPHA, DELTA,
SECRET: ALPHA, DELTA, SIGMA_2,
SECRET: ALPHA, DELTA, SIGMA_2, UNITED STATES, GREAT BRITIAN, SPAIN
PL/SQL procedure successfully completed.
SQL>
SQL> execute sys.ps_LN11('R:usa,b,s'); Level: Group
R
usa
b
s
4
RESTRICTED:
RESTRICTED: UNITED STATES, GREAT BRITIAN, SPAIN
PL/SQL procedure successfully completed.
SQL>     
Thanks in advance for any help on this that you can provide.
Al

from the manual
THE POWER KEY turns on or off both your STB and TV when you are in STB mode. (If you have a DVR STB, the DVR will continue to record scheduled programs when off.) However, you can re-program how the Power Key works.
1. Press and hold the STB Key
2. While holding down the STB Key Press OK
3. Release both keys. The Device Keys will blink twice.
4. Press 9-7-7 The STB key will blink twice
5. One after the other, press each Device Key you want the Power Key to control in the order you want them to turn on or off.
6. Press OK when done. The STB key will blink three times to indicate success.
For example to program the power key to turn on or off your TV, AUX and STB, in that order, with one press of power you would press (STB + OK) 977, TV once, Aux once, STB once, and then hit OK
http://www22.verizon.com/NROneRetail/NR/rdonlyres/2DEF67C9-87F0-4B46-B1BD-A40472BC281A/0/PhilipsRC14...
that should help you make it so the tv and the box turn on at the same time.   
Power
If you want the Power Key to control multiple devices at once…
For example, to program the Power Key to turn on or off your TV, AUX and STB, in that order, with one press of

Similar Messages

Maybe you are looking for