 	    SET bit = bit-1;
 	    SET mask = left_shift(cast(2 as bigint),bit);
 	    CASE 
-		WHEN (bit_and(mask,value)=0) THEN SET out = out || '';
+		WHEN (bit_and(mask,val)=0) THEN SET out = out || '';
 		ELSE SET out = out || (coalesce((select name from TiMask where value=mask),'')||' ');
 	    END CASE;
 	END WHILE;
     RETURN out;
 END;
 
-CREATE FUNCTION fPhotoModeN(value int)
+CREATE FUNCTION fPhotoModeN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM PhotoMode
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fPhotoMode(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fPhotoMode(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value
 	FROM PhotoMode
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fPhotoTypeN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fPhotoTypeN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM PhotoType
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fPhotoType(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fPhotoType(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value
 	FROM PhotoType
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fMaskTypeN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fMaskTypeN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM MaskType
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fMaskType(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fMaskType(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value
 	FROM MaskType
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fFieldQualityN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fFieldQualityN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM FieldQuality
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fFieldQuality(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fFieldQuality(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value
 	FROM FieldQuality
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fPspStatus(name varchar(40))
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fPspStatus(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value
 	FROM PspStatus
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fPspStatusN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fPspStatusN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM PspStatus
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fFramesStatus(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fFramesStatus(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value
 	FROM FramesStatus
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fFramesStatusN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fFramesStatusN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM FramesStatus
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fSpecClass(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fSpecClass(nme varchar(40))
 RETURNS INTEGER
 BEGIN
 RETURN ( SELECT value 
 	FROM SpecClass
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fSpecClassN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fSpecClassN(val int)
 RETURNS varchar(40)
 BEGIN
 RETURN ( SELECT name
 	FROM SpecClass
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fSpecLineNames(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fSpecLineNames(nme varchar(40))
 RETURNS INTEGER
 BEGIN
     RETURN ( SELECT value
 	FROM SpecLineNames
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fSpecLineNamesN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fSpecLineNamesN(val int)
 RETURNS varchar(40)
 BEGIN
     RETURN ( SELECT name
 	FROM SpecLineNames
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fSpecZStatusN(value int)
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fSpecZStatusN(val int)
 RETURNS varchar(40)
 BEGIN
     RETURN ( SELECT name
 	FROM SpecZStatus
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fSpecZStatus(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fSpecZStatus(nme varchar(40))
 RETURNS INTEGER
 BEGIN
     RETURN ( SELECT value
 	FROM SpecZStatus
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fHoleType(name varchar(40))
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fHoleType(nme varchar(40))
 RETURNS INTEGER
 BEGIN
     RETURN ( SELECT value
 	FROM HoleType
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fHoleTypeN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fHoleTypeN(val int)
 RETURNS varchar(40)
 BEGIN
     RETURN ( SELECT name
 	FROM HoleType
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fObjType(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fObjType(nme varchar(40))
 RETURNS INTEGER
 BEGIN
     RETURN ( SELECT value
 	FROM ObjType
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fObjTypeN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fObjTypeN(val int)
 RETURNS varchar(40)
 BEGIN
     RETURN ( SELECT name
 	FROM ObjType
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fProgramType(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fProgramType(nme varchar(40))
 RETURNS INTEGER
 BEGIN
     RETURN ( SELECT value
 	FROM ProgramType
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fProgramTypeN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fProgramTypeN(val int)
 RETURNS varchar(40)
 BEGIN
     RETURN ( SELECT name
 	FROM ProgramType
-	WHERE value = value
-	);
-END;
-
-CREATE FUNCTION fCoordType(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+CREATE FUNCTION fCoordType(nme varchar(40))
 RETURNS INTEGER
 BEGIN
     RETURN ( SELECT value
 	FROM CoordType
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fCoordTypeN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fCoordTypeN(val int)
 RETURNS varchar(40)
 BEGIN
     RETURN ( SELECT name
 	FROM CoordType
-	WHERE value = value
-	);
-END;
-
-
-CREATE FUNCTION fFieldMask(name varchar(40))
+	WHERE value = val
+	);
+END;
+
+
+CREATE FUNCTION fFieldMask(nme varchar(40))
 RETURNS int
 BEGIN
 RETURN ( SELECT cast(value as int)
 	FROM FieldMask
-	WHERE name = UPPER(name)
-	);
-END;
-
-CREATE FUNCTION fFieldMaskN(value int)
+	WHERE name = UPPER(nme)
+	);
+END;
+
+CREATE FUNCTION fFieldMaskN(val int)
 RETURNS varchar(1000)
 BEGIN
     DECLARE bit int, mask bigint, out varchar(2000);

	    SET bit = bit-1;
	    SET mask = left_shift(cast(2 as bigint),bit);
	    CASE 
		WHEN (bit_and(mask,value)=0) THEN SET out = out || ''; 
		ELSE SET out = out || (coalesce((select name from SecTarget where value=mask),'')||' ');
	    END CASE;
	END WHILE;
    RETURN out;
END;

CREATE FUNCTION fInsideMask(name varchar(40))
RETURNS smallint
BEGIN
RETURN ( SELECT cast(value as tinyInt)
	FROM InsideMask
	WHERE name = UPPER(name)
	);
END;

CREATE FUNCTION fInsideMaskN(value smallint)
RETURNS varchar(1000)
BEGIN
    DECLARE bit smallint, mask smallint, out varchar(2000);

	    SET bit = bit-1;
	    SET mask = left_shift(cast(2 as bigint),bit);
	    CASE 
		WHEN (bit_and(mask,val)=0) THEN SET out = out || '';
		ELSE SET out = out || (coalesce((select name from SpecZWarning where value=mask),'')||' ');
	    END CASE;
	END WHILE;
    RETURN out;
END;

CREATE FUNCTION fImageMask(nme varchar(40))
RETURNS int
BEGIN
    RETURN ( SELECT cast(value as int)
	FROM ImageMask
	WHERE name = UPPER(nme)
	);
END;

CREATE FUNCTION fImageMaskN(val int)
RETURNS varchar(1000)
BEGIN
    DECLARE bit int, mask bigint, out varchar(2000);
