SETsNameData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `name_data` UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_name_data` ',CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `name_data` AS subdata WHERE subdata.value ',o,' ? UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_name_data` AS subdata WHERE subdata.value ',o,'?'));
SETsEnumData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `enum_data` UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_enum_data` ',CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `enum_data` AS subdata WHERE subdata.value ',o,' ? UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_enum_data` AS subdata WHERE subdata.value ',o,'?'));
SETsRefData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `reference_data` UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_reference_data`',IF(refIdsTableISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `reference_data` AS subdata WHERE EXISTS (SELECT 1 FROM `',refIdsTable,'` AS refIdsTable WHERE subdata.value=refIdsTable.id LIMIT 1) UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_reference_data` AS subdata WHERE EXISTS (SELECT 1 FROM `',refIdsTable,'` AS refIdsTable WHERE subdata.value=refIdsTable.id LIMIT 1)')));
IFo="!="ANDrefIdsTableISNOTNULLTHEN
SETexistence_op="NOT EXISTS";
ENDIF;
SETsRefData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `reference_data` UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_reference_data`',IF(refIdsTableISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `reference_data` AS subdata WHERE ',existence_op,' (SELECT 1 FROM `',refIdsTable,'` AS refIdsTable WHERE subdata.value=refIdsTable.id LIMIT 1) UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_reference_data` AS subdata WHERE ',existence_op,' (SELECT 1 FROM `',refIdsTable,'` AS refIdsTable WHERE subdata.value=refIdsTable.id LIMIT 1)')));
SETsDoubleData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT subdata.domain_id, subdata.entity_id, _get_head_iversion(subdata.entity_id) AS _iversion, subdata.property_id FROM `double_data` AS subdata UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_double_data` ',IF(vDoubleISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id), property_id FROM `double_data` AS subdata WHERE ',getDoubleWhereClause(vDouble,unit_sig,vDoubleStdUnit,stdUnit_sig,o),' UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_double_data` AS subdata WHERE ',getDoubleWhereClause(vDouble,unit_sig,vDoubleStdUnit,stdUnit_sig,o))));
SETsIntData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT subdata.domain_id, subdata.entity_id, _get_head_iversion(subdata.entity_id) AS _iversion, subdata.property_id FROM `integer_data` AS subdata UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_integer_data`',IF(vIntISNULLANDvDoubleStdUnitISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `integer_data` AS subdata WHERE ',getDoubleWhereClause(vInt,unit_sig,vDoubleStdUnit,stdUnit_sig,o),' UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_integer_data` AS subdata WHERE ',getDoubleWhereClause(vInt,unit_sig,vDoubleStdUnit,stdUnit_sig,o))));
SETsDatetimeData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `datetime_data` UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_datetime_data`',IF(vDateTimeISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, _get_head_iversion(entity_id) AS _iversion, property_id FROM `datetime_data` AS subdata WHERE ',getDateTimeWhereClause(vDateTime,o),' UNION ALL SELECT DISTINCT domain_id, entity_id, _iversion, property_id FROM `archive_datetime_data` AS subdata WHERE ',getDateTimeWhereClause(vDateTime,o))));
...
...
@@ -220,7 +224,10 @@ POV_LABEL: BEGIN
SETsTextData=IF(vTextISNULL,'SELECT DISTINCT domain_id, entity_id, property_id FROM `text_data`',CONCAT('SELECT DISTINCT domain_id, entity_id, property_id FROM `text_data` AS subdata WHERE subdata.value ',o,' ?'));
SETsNameData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `name_data`',CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `name_data` AS subdata WHERE subdata.value ',o,' ?'));
SETsEnumData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `enum_data`',CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `enum_data` AS subdata WHERE subdata.value ',o,' ?'));
SETsRefData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data`',IF(refIdsTableISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data` AS subdata WHERE EXISTS (SELECT 1 FROM `',refIdsTable,'` AS refIdsTable WHERE subdata.value=refIdsTable.id LIMIT 1)')));
IFo="!="ANDrefIdsTableISNOTNULLTHEN
SETexistence_op="NOT EXISTS";
ENDIF;
SETsRefData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data`',IF(refIdsTableISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `reference_data` AS subdata WHERE ',existence_op,' (SELECT 1 FROM `',refIdsTable,'` AS refIdsTable WHERE subdata.value=refIdsTable.id LIMIT 1)')));
SETsDoubleData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT subdata.domain_id, subdata.entity_id, subdata.property_id FROM `double_data` AS subdata',IF(vDoubleISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `double_data` AS subdata WHERE ',getDoubleWhereClause(vDouble,unit_sig,vDoubleStdUnit,stdUnit_sig,o))));
SETsIntData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT subdata.domain_id, subdata.entity_id, subdata.property_id FROM `integer_data` AS subdata',IF(vIntISNULLANDvDoubleStdUnitISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `integer_data` AS subdata WHERE ',getDoubleWhereClause(vInt,unit_sig,vDoubleStdUnit,stdUnit_sig,o))));
SETsDatetimeData=IF(vTextISNULL,' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `datetime_data`',IF(vDateTimeISNULL,NULL,CONCAT(' UNION ALL SELECT DISTINCT domain_id, entity_id, property_id FROM `datetime_data` AS subdata WHERE ',getDateTimeWhereClause(vDateTime,o))));