![]() |
SQL-J Language Reference
|
Reference Manual |
Field AccessYou can access the field of an object or class. Object fields can be static or non-static, and are accessed from instances of Java classes. Class fields are static, and are accessed from Java classes. Only public fields are accessible through SQL-J. Private, protected, and package fields are not accessible through SQL-J. The fields that can be accessed are those that are declared as public in the Java class of the expression's declared data type. The "declared" data type of an expression is its type as determined by the declared types of columns, the declared return types of methods, and the expected result types of the various SQL-J expressions based on the operand(s) involved in the expressions. Syntax
{ Field Access ExamplesVALUES (CLASS java.lang.Integer)->MAX_VALUE
-- Accessing a static field
-- access a non-static field Interaction with Java Data TypesYou can perform field accesses on any SQL-J expression that evaluates Java object or class. Every SQL-J expression has an SQL-J type; every SQL-J type has a corresponding Java class. This means that you can perform field accesses on the corresponding class of SQL-J expressions, returning the result of the field access on that class. The field can be in the corresponding class or in any class within the superclass hierarchy. Field Access and Type ConversionsThe values returned by field accesses are converted to SQL-J types in most cases. For more information about the Java to SQL-J type conversion of return values, see Java to SQL-J Type Correspondence. Field Access and Null ValuesPrimitive types in java (boolean, char, byte, short, int, long, float, and double) cannot be null. So, when a null value is used to reference a non-static field, the field reference evaluates to null only if the value is being returned to the SQL domain. If the value is being returned to another Java construct, a NullPointerException is raised. For example, in the following SQL-J statement, where the city column is null, a null is returned:
SELECT city->language However, the situation changes when the return value of that method call is passed to another Java construct:
SELECT NEW java.lang.String(city->language) In this situation, if the City column contains any nulls, a NullPointerException is raised because the null value is passed to the Java constructor, which does not accept nulls. Static Field Access and Null ValuesIt is possible to access a static field, however, off of a null receiver. In the following example, the value of the static field is returned, not an SQL NULL: VALUES CAST (NULL AS Tour)->ECONOMYTOURLEVEL Class Alias and Column Name AmbiguitySee the discussion under Method Invocation. |
|
![]() Cloudscape Version 3.6 For information about Cloudscape technical support, go to: www.cloudscape.com/support/.Copyright © 1998, 1999, 2000 Informix Software, Inc. All rights reserved. |