What are bind variables?

You can add bind variables to a hand-coded SQL query when creating database portlets such as charts, reports, calendars, frame drivers, and dynamic pages. Each bind variable corresponds to a column in the table or view on which the database portlet is based and creates an entry field in the customization form for the database portlet. Users can enter values in the entry fields to select the column data to display in the database portlet.

Syntax

A bind variable appears in a SQL query as an alphanumeric string preceded by a colon (:var1, :var2, :var3,&ldots;). For example, the following SQL query creates entry fields for SALARY and DEPT columns of the SCOTT.EMP table:

select ename, sal, dept

from scott.emp

where sal = :salary and deptno like :dept

Entering this SQL query creates a customization form with two text entry fields. The first allows the user to select a salary. The second field selects a department number. When the user clicks a button on the customization form to create the database portlet, Oracle Portal uses the values that the user typed in the entry fields.

You do not need to know SQL to specify bind variables. You can identify columns that will accept parameters in the Column field in the Customization Form Display Options step of several database portlet build wizards.

Using Lists of Values

You can also specify a List of Values for the table or view column associated with each bind variable. Instead of prompting the end user of the customization form with a simple entry field to type values, a group of possible values for the entry field displays. If you specify a List of Values for the DEPT column shown in the previous example, the customization form might contain a Department list with the selections Accounting, Operations, Research, and Sales.