Previous Next JavaScript must be enabled to correctly display this content

## Accessing metadata

You can access the metadata of a BoundStatement, PreparedStatement or StatementResult by using the `getResultDef()` method.

Additionally, you can use the `getFields().size()`, `getFieldsName()`, and `getField()` `RecordDef` methods to obtain the number of fields, field name, and field type respectively.

For example:

    // store handle creation omitted.

    ...

    // Access metadata on PreparedStatement or BoundStatement
    PreparedStatement pStmt = store.prepare(
       "DECLARE $minAge integer; $maxAge integer;  " +
       "SELECT id, firstName FROM users WHERE age >= $minAge
       and age < $maxAge ");

    RecordDef recodDef = pStmt.getResultDef();
    int noOfFields = recodDef.getFields().size();
    String fieldName = recodDef.getFieldName(0);  // fieldName is "$minAge";
    FieldDef fieldType = recodDef.getField(0);    // feldType is IntegerDef

    // Access metadata on StatementResult
    StatementResult result = store.executeSync("SELECT * FROM Users WHERE
    (age > 18 and age < 30)");

    recordDef = result.getResultDef();

Note:

DDL operations do not have metadata.