<x:sql>
An x:sql element is used to specify the SQL statement to be executed for an x:select, x:modify, or x:procedureCall action.
Syntax
<x:sql> </x:sql>The statement is specified as the body of this element.
The statement may be parameterized at either of two levels. At the first level, JSP syntax can be used in the statement to cause parameter substitution into the statement before it is submitted to the database. For example:
SELECT * FROM EMPLOYEE WHERE WORKDEPT = <%= request.getParameter("department") %>At the second level, the statement submitted to the database contains parameters, and substitution occurs in database processing. In this case, a parameter can be represented either as ? or as :name (where name is a case-sensitive name for the parameter). The following are all examples of this:
SELECT * FROM EMPLOYEE WHERE WORKDEPT = ? SELECT * FROM EMPLOYEE WHERE WORKDEPT = :dept DELETE FROM EMPLOYEE WHERE EMPNO = ? DELETE FROM EMPLOYEE WHERE EMPNO = :employee CALL GETDEPT (?, ?) CALL GETDEPT (:number, :name) :deptno = CALL GETNUMBER (:deptname)The parameters in a statement cannot use a mixture of the :name syntax and the ? Syntax. All parameters must use one or the other.