SQL and BQL
Compare SQL and BQL query elements through an example that maps tables, inline views, and bind variables to BQL components.
Business Object Query Language (BQL) retains SELECT syntax. Business views replace tables, attributes replace columns, and query components are wrapped in JSON so that Data Extraction can register, schedule, and run the query.
The following example compares a BI Publisher SQL query with the equivalent BQL query.
| SQL element | BQL element | Description |
|---|---|---|
| Tables | viewQueries |
Maps each alias to an extract view. |
| Inline view | namedSelects |
Retains the subquery with a name. |
Outer SELECT statement |
select |
Defines the final query that reads from the named select. |
| Bind variable | parameters |
Defines a parameter. For example, :p_item_number
becomes pItemNumber. |
Download and review the Oracle Business Object Mapping spreadsheet to identify how database tables map to business objects, extract business views, and modules for query design and data validation.
BI Publisher SQL
SELECT DISTINCT oh.item_number,
oh.subinventory_code,
oh.lot_number
FROM (
SELECT esi.item_number,
ohq.subinventory_code,
ohq.lot_number
FROM egp_system_items_b esi,
inv_onhand_quantities_detail ohq
WHERE ohq.inventory_item_id = esi.inventory_item_id
AND ohq.organization_id = esi.organization_id
AND esi.item_number = NVL(:p_item_number, esi.item_number)
) oh
ORDER BY oh.item_number
Business Object Query Language
{
"viewQueries": {
"ItemBO": {
"businessObject": "Item",
"view": "itemsExtract"
},
"OnhandBO": {
"businessObject": "OnhandQuantityDetail",
"view": "onhandQuantitiesExtract"
}
},
"namedSelects": [
{
"name": "onhandSubQuery",
"select": "SELECT esi.itemNumber, ohq.subinventoryCode, ohq.lotNumber FROM ItemBO esi, OnhandBO ohq WHERE ohq.itemId = esi.itemId AND ohq.organizationId = esi.organizationId AND esi.itemNumber = NVL(:pItemNumber, esi.itemNumber)"
}
],
"select": "SELECT DISTINCT itemNumber, subinventoryCode, lotNumber FROM onhandSubQuery ORDER BY itemNumber",
"parameters": [
"pItemNumber"
]
}