CREATE OR REPLACE FUNCTION Dec_To_Bin_To_Char ( pcLoginLevel IN VARCHAR2 ) RETURN VARCHAR2 -- This function should take a character string of numbers and convert -- it into a NUMBER. Then loop through all the possible 32 BITS that -- will reresent the different user groups stored in the field -- "EMP.Login_Lvl" And then return the BIT equvilant of the passed value. -- In character format. IS lnNumLoginLvl NUMBER; lcReturnString VARCHAR2; lnBitCntr NUMBER; BEGIN lnNumLoginLvl := TO_NUMBER(pcLoginLevel); lcReturnString := ''; -- Loop backwards through all the possible bits. FOR lnBitCntr IN REVERSE 0 .. 31 LOOP IF lnNumLoginLvl BETWEEN POWER( 2, lnBitCntr ) AND POWER( 2, ( lnBitCntr + 1 ) ) - 1 THEN -- Add '1' to indicate the bit was set. lcReturnString := lcReturnString || '1'; -- Remove the bit placement from the main varaible. lnNumLoginLvl := lnNumLoginLvl - POWER( 2, lnBitCntr ); ELSE -- Add '0' to indicate the bit was NOT set. lcReturnString := lcReturnString || '0'; END IF; END LOOP; -- Return the bit string. RETURN lcReturnString; END Dec_To_Bin_To_Char; /TIA