You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Bitfields allow for naming and accessing sequences of bits in a column.

Defining bitfields with CREATE TABLE

When creating a table with a bitfield column using the CREATE TABLE statement, the type of the column needs to be already defined with CREATE TYPE, for example:

CREATE TYPE bf AS (f1 bit1, f2 bit2); 
CREATE TABLE foo AS 
  ( x INTEGER, y DOUBLE, v STRING, status bf) 
ON 'new_api_example.odb';

In the above example we have declared a bitfield type called bf, consisting of two members: f1 and f2. f1 occupies 1 bit ("bit1"), f2 2 bits ("bit2").

Later the type bf was used to declare column status in the CREATE TABLE statement.

Referring to bitfield members

Syntax for accessing a member of a bitfield is:

<column-name>.<bitfield-member-name>

In case it is necessary to specify table name when referring to a column, correct way of referring to a member is:

<column-name>.<bitfield-member-name>@<table-name>

for example:

report_status.active@hdr

 

Expanding list of members with star (*) operator

The list of bitfield members can be expanded with the star (*) operator, for example:

report_status.*@hdr

will be expanded to

report_status.active@hdr, report_status.passive@hdr, report_status.rejected@hdr, report_status.blacklisted@hdr, report_status.use_emiskf_only@hdr

  • No labels