IBM PureQuery: Difference between revisions

Content deleted Content added
Line 45:
Inline Style Example:
 
<source lang="java" enclose="div">
Data data = DataFactory.getData (datasource);
// Insert an employee of type Employee bean in the database
data.update("insert into EMPLOYEE (EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY, BONUS, COMM) values( :employeeNumber, :firstName, :midinit, :lastname, :workdept, :phoneno, :hiredate, :job, :edlevel, :sex, :birthdate, :salary, :bonus, :commission)", employee);
BONUS, COMM) values( :employeeNumber, :firstName, :midinit, :lastname, :workdept, :phoneno, :hiredate, :job, :edlevel, :sex,
:birthdate, :salary, :bonus, :commission)", employee);
 
// Query the database for employees
Line 61 ⟶ 59:
 
Annotated Method Style Example:
<source lang="java" enclose="div">
// Annotate createEmployee method with sql to execute when method is invoked
@Update(sql="insert into EMPLOYEE (EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY, BONUS, COMM) values( :employeeNumber, :firstName, :midinit, :lastname, :workdept, :phoneno, :hiredate, :job, :edlevel, :sex, :birthdate, :salary, :bonus, :commission)")
BONUS, COMM) values( :employeeNumber, :firstName, :midinit, :lastname, :workdept, :phoneno, :hiredate, :job, :edlevel,
:sex, :birthdate, :salary, :bonus, :commission)")
int createEmployee(Employee e);
 
// Annotate getEmployees method with sql to execute when method is invoked
@Select(sql="select EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY, BONUS, COMM from EMPLOYEE")
SALARY, BONUS, COMM from EMPLOYEE")
Employee getEmployees();
 
// Annotate getEmployee method with sql to execute when method is invoked
@Select(sql="select EMPNO, FIRSTNME, MIDINIT, LASTNAME, WORKDEPT, PHONENO, HIREDATE, JOB, EDLEVEL, SEX, BIRTHDATE, SALARY, BONUS, COMM from EMPLOYEE where EMPNO = :employeeNumber")
SALARY, BONUS, COMM from EMPLOYEE where EMPNO = :employeeNumber")
Employee getEmployee(Employee e);
</source>