Integrate Karsten's autocompletion from trunk revisions 5521 and 5670

FR [2003044] Autocomplete for Textfields
http://sourceforge.net/tracker/index.php?func=detail&aid=2003044&group_id=176962&atid=879335
[Ctrl + Tab] iterates through all available matches
This commit is contained in:
Carlos Ruiz 2008-07-29 20:40:22 +00:00
parent 524147954a
commit b8200b10ca
4 changed files with 88 additions and 191 deletions

View File

@ -1,16 +1,11 @@
CREATE OR REPLACE VIEW AD_FIELD_V CREATE OR REPLACE VIEW AD_FIELD_V
(AD_WINDOW_ID, AD_TAB_ID, AD_FIELD_ID, AD_TABLE_ID, AD_COLUMN_ID, (AD_WINDOW_ID, AD_TAB_ID, AD_FIELD_ID, AD_TABLE_ID, AD_COLUMN_ID, NAME, DESCRIPTION, HELP, ISDISPLAYED,
NAME, DESCRIPTION, HELP, ISDISPLAYED, DISPLAYLOGIC, DISPLAYLOGIC, DISPLAYLENGTH, SEQNO, SORTNO, ISSAMELINE, ISHEADING, ISFIELDONLY, ISREADONLY, ISENCRYPTEDFIELD,
DISPLAYLENGTH, SEQNO, SORTNO, ISSAMELINE, ISHEADING, OBSCURETYPE, COLUMNNAME, COLUMNSQL, FIELDLENGTH, VFORMAT, DEFAULTVALUE, ISKEY, ISPARENT, ISMANDATORY, ISIDENTIFIER,
ISFIELDONLY, ISREADONLY, ISENCRYPTEDFIELD, OBSCURETYPE, COLUMNNAME, ISTRANSLATED, AD_REFERENCE_VALUE_ID, CALLOUT, AD_REFERENCE_ID, AD_VAL_RULE_ID, AD_PROCESS_ID, ISALWAYSUPDATEABLE,
COLUMNSQL, FIELDLENGTH, VFORMAT, DEFAULTVALUE, ISKEY, READONLYLOGIC, MANDATORYLOGIC, ISUPDATEABLE, ISENCRYPTEDCOLUMN, ISSELECTIONCOLUMN, TABLENAME, VALUEMIN, VALUEMAX,
ISPARENT, ISMANDATORY, ISIDENTIFIER, ISTRANSLATED, AD_REFERENCE_VALUE_ID, FIELDGROUP, VALIDATIONCODE, INCLUDED_TAB_ID, FIELDGROUPTYPE, ISCOLLAPSEDBYDEFAULT, INFOFACTORYCLASS, ISAUTOCOMPLETE) AS
CALLOUT, AD_REFERENCE_ID, AD_VAL_RULE_ID, AD_PROCESS_ID, ISALWAYSUPDATEABLE, SELECT t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID,
READONLYLOGIC, MANDATORYLOGIC, ISUPDATEABLE, ISENCRYPTEDCOLUMN, ISSELECTIONCOLUMN,
TABLENAME, VALUEMIN, VALUEMAX, FIELDGROUP, VALIDATIONCODE,
INCLUDED_TAB_ID, FIELDGROUPTYPE, IsCollapsedByDefault, InfoFactoryClass)
AS
SELECT t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID,
f.NAME, f.Description, f.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength, f.NAME, f.Description, f.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength,
f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly, f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly,
f.IsEncrypted AS IsEncryptedField, f.ObscureType, f.IsEncrypted AS IsEncryptedField, f.ObscureType,
@ -26,7 +21,8 @@ SELECT t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_
tbl.TableName, c.ValueMin, c.ValueMax, tbl.TableName, c.ValueMin, c.ValueMax,
fg.NAME AS FieldGroup, vr.Code AS ValidationCode, fg.NAME AS FieldGroup, vr.Code AS ValidationCode,
f.Included_Tab_ID, fg.FieldGroupType, fg.IsCollapsedByDefault, f.Included_Tab_ID, fg.FieldGroupType, fg.IsCollapsedByDefault,
COALESCE(f.InfoFactoryClass, c.InfoFactoryClass) as InfoFactoryClass COALESCE(f.InfoFactoryClass, c.InfoFactoryClass) as InfoFactoryClass,
c.IsAutocomplete
FROM AD_FIELD f FROM AD_FIELD f
INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID) INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID)
LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID) LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID)
@ -35,4 +31,4 @@ FROM AD_FIELD f
INNER JOIN AD_REFERENCE r ON (c.AD_Reference_ID = r.AD_Reference_ID) INNER JOIN AD_REFERENCE r ON (c.AD_Reference_ID = r.AD_Reference_ID)
LEFT OUTER JOIN AD_VAL_RULE vr ON (vr.AD_Val_Rule_ID = COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID)) LEFT OUTER JOIN AD_VAL_RULE vr ON (vr.AD_Val_Rule_ID = COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID))
WHERE f.IsActive = 'Y' WHERE f.IsActive = 'Y'
AND c.IsActive = 'Y' AND c.IsActive = 'Y';

View File

@ -1,40 +1,36 @@
CREATE OR REPLACE VIEW AD_FIELD_VT CREATE OR REPLACE VIEW AD_FIELD_VT (AD_LANGUAGE, AD_WINDOW_ID, AD_TAB_ID, AD_FIELD_ID, AD_TABLE_ID,
(AD_LANGUAGE, AD_WINDOW_ID, AD_TAB_ID, AD_FIELD_ID, AD_TABLE_ID, AD_COLUMN_ID, NAME, DESCRIPTION, HELP, ISDISPLAYED, DISPLAYLOGIC, DISPLAYLENGTH, SEQNO, SORTNO, ISSAMELINE,
AD_COLUMN_ID, NAME, DESCRIPTION, HELP, ISDISPLAYED, ISHEADING, ISFIELDONLY, ISREADONLY, ISENCRYPTEDFIELD, OBSCURETYPE, COLUMNNAME, COLUMNSQL, FIELDLENGTH, VFORMAT,
DISPLAYLOGIC, DISPLAYLENGTH, SEQNO, SORTNO, ISSAMELINE, DEFAULTVALUE, ISKEY, ISPARENT, ISMANDATORY, ISIDENTIFIER, ISTRANSLATED, AD_REFERENCE_VALUE_ID, CALLOUT,
ISHEADING, ISFIELDONLY, ISREADONLY, ISENCRYPTEDFIELD, OBSCURETYPE, AD_REFERENCE_ID, AD_VAL_RULE_ID, AD_PROCESS_ID, ISALWAYSUPDATEABLE, READONLYLOGIC, MANDATORYLOGIC, ISUPDATEABLE,
COLUMNNAME, COLUMNSQL, FIELDLENGTH, VFORMAT, DEFAULTVALUE, ISENCRYPTEDCOLUMN, ISSELECTIONCOLUMN, TABLENAME, VALUEMIN, VALUEMAX, FIELDGROUP, VALIDATIONCODE, INCLUDED_TAB_ID,
ISKEY, ISPARENT, ISMANDATORY, ISIDENTIFIER, ISTRANSLATED, FIELDGROUPTYPE, ISCOLLAPSEDBYDEFAULT, INFOFACTORYCLASS, ISAUTOCOMPLETE) AS
AD_REFERENCE_VALUE_ID, CALLOUT, AD_REFERENCE_ID, AD_VAL_RULE_ID, AD_PROCESS_ID, SELECT trl.AD_LANGUAGE, t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID,
ISALWAYSUPDATEABLE, READONLYLOGIC, MANDATORYLOGIC, ISUPDATEABLE, ISENCRYPTEDCOLUMN, trl.NAME, trl.Description, trl.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength,
ISSELECTIONCOLUMN, TABLENAME, VALUEMIN, VALUEMAX, FIELDGROUP, f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly,
VALIDATIONCODE, INCLUDED_TAB_ID, FIELDGROUPTYPE, IsCollapsedByDefault, InfoFactoryClass) f.IsEncrypted AS IsEncryptedField, f.ObscureType,
AS c.ColumnName, c.ColumnSQL, c.FieldLength, c.VFormat,
SELECT trl.AD_LANGUAGE, t.AD_Window_ID, f.AD_Tab_ID, f.AD_Field_ID, tbl.AD_Table_ID, f.AD_Column_ID, COALESCE(f.DefaultValue, c.DefaultValue) AS DefaultValue,
trl.NAME, trl.Description, trl.Help, f.IsDisplayed, f.DisplayLogic, f.DisplayLength, c.IsKey, c.IsParent,
f.SeqNo, f.SortNo, f.IsSameLine, f.IsHeading, f.IsFieldOnly, f.IsReadOnly, COALESCE(f.IsMandatory, c.IsMandatory) AS IsMandatory,
f.IsEncrypted AS IsEncryptedField, f.ObscureType, c.IsIdentifier, c.IsTranslated, COALESCE(f.AD_Reference_Value_ID, c.AD_Reference_Value_ID) AS AD_Reference_Value_ID,
c.ColumnName, c.ColumnSQL, c.FieldLength, c.VFormat, c.Callout, COALESCE(f.AD_Reference_ID, c.AD_Reference_ID) AS AD_Reference_ID,
COALESCE(f.DefaultValue, c.DefaultValue) AS DefaultValue, COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID) as AD_Val_Rule_ID, c.AD_Process_ID, c.IsAlwaysUpdateable,
c.IsKey, c.IsParent, c.ReadOnlyLogic, c.MandatoryLogic, c.IsUpdateable, c.IsEncrypted AS IsEncryptedColumn, c.IsSelectionColumn,
COALESCE(f.IsMandatory, c.IsMandatory) AS IsMandatory, tbl.TableName, c.ValueMin, c.ValueMax,
c.IsIdentifier, c.IsTranslated, COALESCE(f.AD_Reference_Value_ID, c.AD_Reference_Value_ID) AS AD_Reference_Value_ID, fgt.NAME AS FieldGroup, vr.Code AS ValidationCode,
c.Callout, COALESCE(f.AD_Reference_ID, c.AD_Reference_ID) AS AD_Reference_ID, f.Included_Tab_ID, fg.FieldGroupType, fg.IsCollapsedByDefault,
COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID) as AD_Val_Rule_ID, c.AD_Process_ID, c.IsAlwaysUpdateable, COALESCE(f.InfoFactoryClass, c.InfoFactoryClass) as InfoFactoryClass,
c.ReadOnlyLogic, c.MandatoryLogic, c.IsUpdateable, c.IsEncrypted AS IsEncryptedColumn, c.IsSelectionColumn, c.IsAutocomplete
tbl.TableName, c.ValueMin, c.ValueMax, FROM AD_FIELD f
fgt.NAME AS FieldGroup, vr.Code AS ValidationCode, INNER JOIN AD_FIELD_TRL trl ON (f.AD_Field_ID = trl.AD_Field_ID)
f.Included_Tab_ID, fg.FieldGroupType, fg.IsCollapsedByDefault, INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID)
COALESCE(f.InfoFactoryClass, c.InfoFactoryClass) as InfoFactoryClass LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID)
FROM AD_FIELD f LEFT OUTER JOIN AD_FIELDGROUP_TRL fgt ON
INNER JOIN AD_FIELD_TRL trl ON (f.AD_Field_ID = trl.AD_Field_ID) (f.AD_FieldGroup_ID = fgt.AD_FieldGroup_ID AND trl.AD_LANGUAGE=fgt.AD_LANGUAGE)
INNER JOIN AD_TAB t ON (f.AD_Tab_ID = t.AD_Tab_ID) LEFT OUTER JOIN AD_COLUMN c ON (f.AD_Column_ID = c.AD_Column_ID)
LEFT OUTER JOIN AD_FIELDGROUP fg ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID) INNER JOIN AD_TABLE tbl ON (c.AD_Table_ID = tbl.AD_Table_ID)
LEFT OUTER JOIN AD_FIELDGROUP_TRL fgt ON INNER JOIN AD_REFERENCE r ON (c.AD_Reference_ID = r.AD_Reference_ID)
(f.AD_FieldGroup_ID = fgt.AD_FieldGroup_ID AND trl.AD_LANGUAGE=fgt.AD_LANGUAGE) LEFT OUTER JOIN AD_VAL_RULE vr ON (vr.AD_Val_Rule_ID=COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID))
LEFT OUTER JOIN AD_COLUMN c ON (f.AD_Column_ID = c.AD_Column_ID) WHERE f.IsActive = 'Y'
INNER JOIN AD_TABLE tbl ON (c.AD_Table_ID = tbl.AD_Table_ID) AND c.IsActive = 'Y';
INNER JOIN AD_REFERENCE r ON (c.AD_Reference_ID = r.AD_Reference_ID)
LEFT OUTER JOIN AD_VAL_RULE vr ON (vr.AD_Val_Rule_ID=COALESCE(f.AD_Val_Rule_ID, c.AD_Val_Rule_ID))
WHERE f.IsActive = 'Y'
AND c.IsActive = 'Y'

View File

@ -1,65 +1,22 @@
CREATE OR CREATE OR REPLACE VIEW ad_field_v AS
REPLACE VIEW ad_field_v AS SELECT t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id,
SELECT t.ad_window_id, f.name, f.description, f.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno,
f.ad_tab_id, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly, f.isencrypted AS isencryptedfield,
f.ad_field_id, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat,
tbl.ad_table_id, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue, c.iskey, c.isparent,
f.ad_column_id, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated,
f.NAME, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout,
f.description, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id,
f.help, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id,
f.isdisplayed, c.isalwaysupdateable, c.readonlylogic, c.mandatorylogic, c.isupdateable,
f.displaylogic, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax,
f.displaylength, fg.name AS fieldgroup, vr.code AS validationcode, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault,
f.seqno, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete
f.sortno, FROM ad_field f
f.issameline, JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id
f.isheading, LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id
f.isfieldonly, LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id
f.isreadonly, JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id
f.isencrypted AS isencryptedfield, JOIN ad_reference r ON c.ad_reference_id = r.ad_reference_id
f.obscuretype, LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id)
c.columnname, WHERE f.isactive = 'Y'::bpchar AND c.isactive = 'Y'::bpchar;
c.columnsql,
c.fieldlength,
c.vformat,
COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue,
c.iskey,
c.isparent,
COALESCE(f.ismandatory, c.ismandatory) AS ismandatory,
c.isidentifier,
c.istranslated,
COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id,
c.callout,
COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id,
COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id,
c.ad_process_id,
c.isalwaysupdateable,
c.readonlylogic,
c.isupdateable,
c.isencrypted AS isencryptedcolumn,
c.isselectioncolumn,
tbl.tablename,
c.valuemin,
c.valuemax,
fg.NAME AS fieldgroup,
vr.code AS validationcode,
f.Included_Tab_ID,
fg.FieldGroupType,
fg.IsCollapsedByDefault AS iscollapsedbydefault,
COALESCE(f.infofactoryclass, c.infofactoryclass) as infofactoryclass
FROM ((((((AD_FIELD f
JOIN AD_TAB t
ON ((f.ad_tab_id = t.ad_tab_id)))
LEFT JOIN AD_FIELDGROUP fg
ON ((f.ad_fieldgroup_id = fg.ad_fieldgroup_id)))
LEFT JOIN AD_COLUMN c
ON ((f.ad_column_id = c.ad_column_id)))
JOIN AD_TABLE tbl
ON ((c.ad_table_id = tbl.ad_table_id)))
JOIN AD_REFERENCE r
ON ((c.ad_reference_id = r.ad_reference_id)))
LEFT JOIN AD_VAL_RULE vr
ON ((vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id))))
WHERE ((f.isactive = 'Y'::bpchar) AND
(c.isactive = 'Y'::bpchar));

View File

@ -1,71 +1,19 @@
CREATE OR CREATE OR REPLACE VIEW ad_field_vt AS
REPLACE VIEW ad_field_vt AS SELECT trl.ad_language, t.ad_window_id, f.ad_tab_id, f.ad_field_id, tbl.ad_table_id, f.ad_column_id, trl.name, trl.description,
SELECT trl.AD_LANGUAGE, trl.help, f.isdisplayed, f.displaylogic, f.displaylength, f.seqno, f.sortno, f.issameline, f.isheading, f.isfieldonly, f.isreadonly,
t.ad_window_id, f.isencrypted AS isencryptedfield, f.obscuretype, c.columnname, c.columnsql, c.fieldlength, c.vformat, COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue,
f.ad_tab_id, c.iskey, c.isparent, COALESCE(f.ismandatory, c.ismandatory) AS ismandatory, c.isidentifier, c.istranslated,
f.ad_field_id, COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id, c.callout, COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id,
tbl.ad_table_id, COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id, c.ad_process_id, c.isalwaysupdateable, c.readonlylogic, c.mandatorylogic, c.isupdateable,
f.ad_column_id, c.isencrypted AS isencryptedcolumn, c.isselectioncolumn, tbl.tablename, c.valuemin, c.valuemax, fgt.name AS fieldgroup, vr.code AS validationcode,
trl.NAME, f.included_tab_id, fg.fieldgrouptype, fg.iscollapsedbydefault, COALESCE(f.infofactoryclass, c.infofactoryclass) AS infofactoryclass, c.isautocomplete
trl.description, FROM ad_field f
trl.help, JOIN ad_field_trl trl ON f.ad_field_id = trl.ad_field_id
f.isdisplayed, JOIN ad_tab t ON f.ad_tab_id = t.ad_tab_id
f.displaylogic, LEFT JOIN ad_fieldgroup fg ON f.ad_fieldgroup_id = fg.ad_fieldgroup_id
f.displaylength, LEFT JOIN ad_fieldgroup_trl fgt ON f.ad_fieldgroup_id = fgt.ad_fieldgroup_id AND trl.ad_language::text = fgt.ad_language::text
f.seqno, LEFT JOIN ad_column c ON f.ad_column_id = c.ad_column_id
f.sortno, JOIN ad_table tbl ON c.ad_table_id = tbl.ad_table_id
f.issameline, JOIN ad_reference r ON c.ad_reference_id = r.ad_reference_id
f.isheading, LEFT JOIN ad_val_rule vr ON vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id)
f.isfieldonly, WHERE f.isactive = 'Y'::bpchar AND c.isactive = 'Y'::bpchar;
f.isreadonly,
f.isencrypted AS isencryptedfield,
f.obscuretype,
c.columnname,
c.columnsql,
c.fieldlength,
c.vformat,
COALESCE(f.defaultvalue, c.defaultvalue) AS defaultvalue,
c.iskey,
c.isparent,
COALESCE(f.ismandatory, c.ismandatory) AS ismandatory,
c.isidentifier,
c.istranslated,
COALESCE(f.ad_reference_value_id, c.ad_reference_value_id) AS ad_reference_value_id,
c.callout,
COALESCE(f.ad_reference_id, c.ad_reference_id) AS ad_reference_id,
COALESCE(f.ad_val_rule_id, c.ad_val_rule_id) AS ad_val_rule_id,
c.ad_process_id,
c.isalwaysupdateable,
c.readonlylogic,
c.isupdateable,
c.isencrypted AS isencryptedcolumn,
c.isselectioncolumn,
tbl.tablename,
c.valuemin,
c.valuemax,
fgt.NAME AS fieldgroup,
vr.code AS validationcode,
f.Included_Tab_ID,
fg.FieldGroupType,
fg.IsCollapsedByDefault AS iscollapsedbydefault ,
COALESCE(f.infofactoryclass, c.infofactoryclass) as infofactoryclass
FROM (((((((AD_FIELD f
JOIN AD_FIELD_TRL trl
ON ((f.ad_field_id = trl.ad_field_id)))
JOIN AD_TAB t
ON ((f.ad_tab_id = t.ad_tab_id)))
LEFT JOIN AD_FIELDGROUP fg
ON (f.AD_FieldGroup_ID = fg.AD_FieldGroup_ID)
LEFT JOIN AD_FIELDGROUP_TRL fgt
ON (((f.ad_fieldgroup_id = fgt.ad_fieldgroup_id) AND
((trl.AD_LANGUAGE)::text = (fgt.AD_LANGUAGE)::text))))
LEFT JOIN AD_COLUMN c
ON ((f.ad_column_id = c.ad_column_id)))
JOIN AD_TABLE tbl
ON ((c.ad_table_id = tbl.ad_table_id)))
JOIN AD_REFERENCE r
ON ((c.ad_reference_id = r.ad_reference_id)))
LEFT JOIN AD_VAL_RULE vr
ON ((vr.ad_val_rule_id = COALESCE(f.ad_val_rule_id, c.ad_val_rule_id))))
WHERE ((f.isactive = 'Y'::bpchar) AND
(c.isactive = 'Y'::bpchar));