If you create your SQL query in a text editor (such as Emacs or vi), the Business Components framework makes it easy to paste it into your XML file:
In the XML file for your View Object, ensure that the CustomQuery attribute for your View Object's <ViewObject...> element is set to "true". That is,
CustomQuery="true"
Enter the following lines in the file:
<SQLQuery><![CDATA[paste your custom SQL here
]]></SQLQuery>For example:
....<ViewObject
Name="DeptView"
OrderBy="Dept.DNAME"CustomQuery="true"ComponentClass="package2.DeptViewImpl" ><SQLQuery><![CDATA[SELECT Dept.DEPTNO, Dept.DNAME, Dept.LOC, Dept.FAXNUM
FROM DEPT Dept]]></SQLQuery>...
Save your XML file.
In the CDATA section, you do not have to quote special characters such as <, >, &, ', or ".
You must use SQL column aliases in your custom SQL query statement so that the names of each column matches its corresponding View Object attribute name (case-insensitively). The wizard does this for you, but if you manually edit the View Object XML file, you must keep this rule in mind.