NonStop Server for Java (NSJ) Programmer's Guide (NSJ 2.0+)

SQL Example
Any SQL data type can (optionally) have a "null indicator," which is two additional bytes of data. A data item of the type
SQL VARCHAR always has two additional bytes of data for its length.
For the following DDL code:
05 a-varchar type sql varchar 6.
05 a-varchar-nullable type sql varchar 6 sqlnullable.
05 c-sqldate type sql date.
05 c-sqldate-nullable type sql date sqlnullable.
ddl2java generates the following Java code, where the suffix _indicator identifies each null indicator and the suffix
_len identifies the length of each VARCHAR data item:
protected String a_varchar_len;
protected String a_varchar;
protected String a_varchar_nullable_indicator;
protected String a_varchar_nullable_len;
protected String a_varchar_nullable;
protected String c_sqldate;
protected String c_sqldate_nullable_indicator;
protected String c_sqldate_nullable;
The preceding Java code is equivalent to the following C code:
struct
{
short len;
char val[6];
} a_varchar;
struct
{
short indicator;
struct
{
short len;
char val[6];
} valu;
} a_varchar_nullable;
char c_sqldate[10];
struct
{
short indicator;
char valu[10];
} c_sqldate_nullable;
Internationalization
ddl2java generates code that encodes Unicode (Java Strings) to international character set strings and that encodes
international character set strings to Unicode. To use this feature, you specify the -e coding option when running
ddl2java. This option identifies a System property that you will set to a coding value when you execute the program that
uses the generated class files.
A System property consists of a key and a value. In this case, you use the -e coding option to identify the key that will be
used for the property. You identify the value (the default encoding) when you run the application that uses the generated
class.
This encoding value will be used to encode PIC X and PIC N fields during run time. For example, consider the following