# Adding Custom Code to a View Object XML File

## Pasting a Custom Query in a View Object XML File

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:

1. 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"

2. 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>

> >       ...

3. Save your XML file.

### Precautions for Editing the View Object 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.