|
2 The Meat of A SQLJ Program
SQL statements in SQLJ / Host expressions / Stored function calls / Stored Procedure calls and argument modes / SQLJ iterator concept / Named iterators / Positional iterators
When you want to embed SQL in Java, you will inevitably use SQLJ statements and in most cases SQLJ iterators. This chapter explains the basic concepts of both.
2.1 SQLJ is Embedded SQL
So how do we issue "COMMIT" to get the changes in our transaction committed, or for that matter how do we write other SQL statements? It's straightforward.
#sql { UPDATE emp SET sal = 3000 WHERE ename = 'SCOTT' };
You can put any SQL statement (including DDL, DML, PL/SQL declarations and blocks) between the curly braces, and it will get sent to the database as is - SQL comments and all!
- Every SQLJ statement must be terminated with a semicolon ";"
- See also SQLJ Developer's Guide and Reference, Chapter 3, Section "Overview of SQLJ Executable Statements".
- (*) What happens if you omit the semicolon ";" at the end of the SQLJ statement (after the closing curly brace)?
What happens if you put a semicolon ";" at the end of the SQL statement (just before the closing curly brace)?
- (**) Write a DDL statement, a DML statement, a PL/SQL block, and a PL/SQL declaration in SQLJ. Sprinkle some SQL comments in.

|