Show TOC Start of Content Area

Background documentation Syntax Overview  Locate the document in its SAP Library structure

An SQLJ source file is a Java source file with special embedded SQLJ-statements, which themselves can contain embedded SQL. SQLJ acts as the glue between Java and SQL.

Java

The Java-parts of the source file follow the lexical and syntactical rules specified by the Java Language Specification.

SQLJ

SQLJ-statements start with “#sql” and end with semicolon “;”. In addition to the keywords reserved in Java, “iterator”, “context” and “with” are reserved keywords within the SQLJ statements. SQLJ statements are case sensitive.

SQL

The SQL text is enclosed in curly brackets “{“ and “}”. SQL statement text is case insensitive. The set of reserved keywords in the SQL statements is defined by the Open SQL grammar. Host variables are prefixed by a colon “:”.

Example

#sql context Ctx with (dataSource = ”jdbc/SYS”);

String var;

#sql [ctx] { Select col into :var FROM tab };

SQLJ syntax. SQLJ statements start with “#sql”. Java and SQLJ code fragments are case sensitive. SQL code fragments are case insensitive. Here, Java fragments are displayed in black, SQLJ fragments are displayed in red and SQL fragments are displayed in blue. Reserved keywords are bold.

Comments

In an SQLJ source file you can use the following comment styles:

·        Java-styled comments (/*…*/ or //)

·        SQL-styled comments (/*…*/ or --)

The SQL-styled comments are only used within the SQL parts of the source code. Outside the SQL fragments, you should use Java-styled comments.

Example

/* #sql context Ctx with (dataSource = "jdbc/SYS");*/

// String var;

#sql [ctx] {

  --Select col into :var FROM tab

};

 

 

 

End of Content Area