You are here:
Sample SQL Statement Generated From a Datasource Contract
This sample shows the SELECT statement generated for a datasource contract
Required Editions
| Available in: Enterprise, Performance, and Unlimited Editions |
This example demonstrates how the SELECT statement looks like for the DsLoCustomerSalesRevenue datasource. The application uses the
column values for the attributes specified in Attributes in the Account_Sales_Data__c table entity and builds the WHERE clause by using the code
defined in QueryCondition. The values for the macros in
QueryCondition are fetched from the parameter
values.
<DataSource name="DsLoCustomerSalesRevenue" backendSystem="sf" businessObjectClass="LoCustomerSalesRevenue" external="false" editableEntity="Account_Sales_Data__c" schemaVersion="2.0">
<Attributes>
<Attribute name="pKey" table="Account_Sales_Data__c" column="Id" />
<Attribute name="netSales" table="Account_Sales_Data__c" column="Sales_Volume__c" />
<Attribute name="year" table="Account_Sales_Data__c" column="Year__c" />
<Attribute name="monthNumInYear" table="Account_Sales_Data__c" column="Month__c" />
</Attributes>
<Entities>
<Entity name="Account_Sales_Data__c" alias="" idAttribute="Id" />
</Entities>
<QueryCondition><![CDATA[
Account_Sales_Data__c.Account__c = #bpaMainPKey#
AND (Account_Sales_Data__c.Year__c = #year#
OR Account_Sales_Data__c.Year__c = #year# - 1)
]]>
</QueryCondition>
<OrderCriteria>
<OrderCriterion entity="Account_Sales_Data__c" attribute="Month__c" direction="ASC" />
<OrderCriterion entity="Account_Sales_Data__c" attribute="Year__c" direction="ASC" />
</OrderCriteria>
<Parameters>
<Parameter name="bpaMainPKey" type="TEXT" />
<Parameter name="year" type="INTEGER" />
</Parameters>
</DataSource>
SELECT statement for DsLoCustomerSalesRevenue datasource
SELECT
Id AS pKey,
Sales_Volume__c AS netSales,
Year__c AS year,
Month__c AS monthNumInYear
FROM Account_Sales_Data__c
WHERE Account_Sales_Data__c.Account__c = #bpaMainPKey#
AND (Account_Sales_Data__c.Year__c = #year#
OR Account_Sales_Data__c.Year__c = #year# - 1)
ORDER BY Month__c ASC, Year__c ASC
Did this article solve your issue?
Let us know so we can improve!

