Sign in or 

| Platform: | Oracle | App: | Tool: | Oracle Forms | |
| DB Ver: | 9.2 | App Ver: | Tool Ver: | 6i | |
| Revision Date: | 28-Mar-2006 | Keywords: | HOWTO, FROM CLAUSE, QUERY DATA SOURCE NAME, WHERE CLAUSE, UNION, SUBQUERY | ||
| Goal | |||||
| To use an alternative to the FROM CLAUSE in a form, OR to base a form on a UNION / QUERY etc | |||||
| Facts | |||||
| Solution | |||||
There has been a requirement to base a form on a sub query, where a view is inappropriate due to the parameters needing to be embedded in the view. Initially setting the block's Query Data Source Type to FROM CLAUSE Query appeared to offer the best solution. However, upon repeated tests, a number of limitations became clear.
Having only glanced at the option of basing a block on a stored procedure, I had a brainwave. Given that a FROM CLAUSE query would have rendered the form incapable of automatically using the INSERT/UPDATE/DELETE functionality, and given that this was acceptable, I considered the following: The Query Data Source Type = TABLE seemed to be very stable. My solution was to use this type, effectively selecting the columns out of a constructed view that had the required columns. I used this view as the base table. In my case, I wanted a query involving many subqueries and a UNION. So first, I created a view that had the columns on the form: CREATE OR REPLACE VIEW xxmg_itemspreader_orgs_v AS Next, I set the Query Data Source Name in the form to the name of the view. | |||||
master_organization_id = :startup_info.master_org_id
AND NVL (eam_enabled_flag, 'N') = NVL (:parameter.EAM_ITEM_FLAG, 'N')
AND inventory_item_id = :control.inventory_item_id
AND EXISTS (
UNIONSELECT 'x'
FROM org_organization_definitions ood
WHERE ood.organization_id = x.organization_id
AND ood.inventory_enabled_flag = 'Y'
)
SELECT order_clause, organization_id, inventory_item_id, organization_code,
organization_name, primary_unit_of_measure_tl, assigned_flag,
cost_of_sales_account, sales_account, expense_account,
encumbrance_account
FROM xxmg_itemspreader_orgs_v x
WHERE 1=1
AND master_organization_id = :startup_info.master_org_id
AND NVL (eam_enabled_flag, 'N') = NVL (:parameter.EAM_ITEM_FLAG, 'N')
AND EXISTS (
SELECT 'x'
FROM org_organization_definitions ood
WHERE ood.organization_id = x.organization_id
AND ood.inventory_enabled_flag = 'Y'
)
AND (inventory_item_id IS NULL
AND organization_id IN (
SELECT organization_id
With a UNION, the ORDER BY clause must reference the numeric position of the column to be ordered, so I used:FROM xxmg_itemspreader_orgs_v
WHERE inventory_item_id IS NULL
MINUS
SELECT organization_id
FROM xxmg_itemspreader_orgs_v
WHERE inventory_item_id = :control.inventory_item_id
))
1 ASC, 7 DESC, 4
|
consultium |
Latest page update: made by consultium
, Oct 7 2009, 1:29 PM EDT
(about this update
About This Update
view changes - complete history) |
|
Keyword tags:
FROM CLAUSE
HOWTO
QUERY DATA SOURCE NAME
SUBQUERY
UNION
WHERE CLAUSE
More Info: links to this page
|