--GL_DAILY_RATES_V
SELECT primary.from_currency,
primary.to_currency,
primary.conversion_date,
ct.user_conversion_type,
ROUND(primary.conversion_rate,18),
ROUND(secondary.conversion_rate,10),
primary.conversion_rate,
secondary.conversion_rate,
primary.rowid,
secondary.rowid,
primary.status_code,
primary.conversion_type,
DECODE(ct.security_flag,'Y', DECODE(fnd_data_security.check_function(1.0,'GL_DAS_RATE_TYPES_V', 'GL_DAS_RATE_TYPES', ct.conversion_type, NULL, NULL, NULL, NULL, fnd_global.user_name), 'T', 'Y', 'N'), 'Y'),
DECODE(ct.security_flag,'Y', DECODE(fnd_data_security.check_function(1.0,'GL_DAS_RATE_TYPES_U', 'GL_DAS_RATE_TYPES', ct.conversion_type, NULL, NULL, NULL, NULL, fnd_global.user_name), 'T', 'Y', 'N'), 'Y'),
DECODE(ct.security_flag,'Y', DECODE(fnd_data_security.check_function(1.0,'GL_DAS_RATE_TYPES_M', 'GL_DAS_RATE_TYPES', ct.conversion_type, NULL, NULL, NULL, NULL, fnd_global.user_name), 'T', 'Y', 'N'), 'Y'),
primary.attribute1,
primary.attribute2,
primary.attribute3,
primary.attribute4,
primary.attribute5,
primary.attribute6,
primary.attribute7,
primary.attribute8,
primary.attribute9,
primary.attribute10,
primary.attribute11,
primary.attribute12,
primary.attribute13,
primary.attribute14,
primary.attribute15,
primary.context,
primary.last_update_date,
primary.last_updated_by,
primary.last_update_login,
primary.created_by,
primary.creation_date
FROM gl_daily_rates secondary,
gl_daily_rates PRIMARY,
gl_daily_conversion_types ct
WHERE secondary.to_currency = primary.from_currency
|| ''
AND secondary.from_currency = primary.to_currency
|| ''
AND secondary.conversion_date = primary.conversion_date + 0
AND secondary.conversion_type = primary.conversion_type
|| ''
AND ct.conversion_type = primary.conversion_type
|| '';
SELECT conversion_rate
FROM GL_DAILY_RATES_V
WHERE status_code != 'D'
AND view_privilege = 'Y'
AND FROM_CURRENCY = 'RMB'
AND TO_CURRENCY = 'HKD'
AND user_conversion_type = 'Corporate'
AND conversion_date = FND_DATE.CANONICAL_TO_DATE(:p_as_of_date)