Package org.compiere.process
Class ViewDefinitionParser
java.lang.Object
org.compiere.process.ViewDefinitionParser
Split the SQL text of a database view (as returned by PostgreSQL pg_get_viewdef or
stored in Oracle ALL_VIEWS.TEXT) into the parts kept in AD_ViewComponent and AD_ViewColumn.
Only the constructs that the view component model can represent are accepted: one or more SELECT statements combined with UNION / UNION ALL.
Only the constructs that the view component model can represent are accepted: one or more SELECT statements combined with UNION / UNION ALL.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOne SELECT statement of the viewstatic final classA column of the select list -
Method Summary
Modifier and TypeMethodDescriptionstatic List<ViewDefinitionParser.Component>Parse the SQL text of a viewstatic StringremoveCasts(String sql) Remove all the PostgreSQL type casts (::type), outside string literals and quoted identifiers.
Some casts are needed by PostgreSQL (e.g. lpad(integer::text, ...)) or define the data type of a column, so the result must be reviewed.
-
Method Details
-
parse
Parse the SQL text of a view- Parameters:
viewSQL- select statement of the view, without the CREATE VIEW part- Returns:
- components, in the order they appear in the view
- Throws:
AdempiereException- with the unsupported construct as message, if the view can't be represented as view components
-
removeCasts
Remove all the PostgreSQL type casts (::type), outside string literals and quoted identifiers.
Some casts are needed by PostgreSQL (e.g. lpad(integer::text, ...)) or define the data type of a column, so the result must be reviewed.- Parameters:
sql-- Returns:
- sql without ::type casts
-