Home

Getting Started

Utilities

Indexing

Omnidex

Development

Tutorials

Quick Links

 

ODXSQL

Commands

Syntax

Options

Example

 

ODXSQL

Special Characters

USE Files

Commands

FLIP

The FLIP command flips the byte ordering on the specified item opposite its current ordering. For example, if a table is currently stored in LITTLE ENDIAN format, FLIP will change the byte ordering to BIG ENDIAN. This can become necessary for example, when a binary file is copied from one operating system to another.

FLIP is not the same as the SET ENDIAN command which only affects the data as it is returned to OdxSQL. FLIP actually affects the data in the file.

The FLIP command can be used on a file, a table in a database, or all the tables in a database.

 

Syntax

FLIP <DATABASE | TABLE | FILE> name [ON [INSTANCE] instance] [WITH options]

FLIP
Required.

DATABASE | TABLE | FILE name
Required. Flip the bytes on an entire database, a single table in a database, or a file. name is the name of the database, table, or file.
DATABASE - Change the byte ordering on every table in the database by using the FLIP DATABASE command. OdxSQL will scan every table to determine which columns need to be flipped, calculate the offsets and perform the flip.
TABLE - Change the byte ordering on any table in the environment catalog. It will scan the table to determine which columns need to be flipped, calculate the necessary offsets and perform the flip.
FILE - Change the byte ordering on a single file. When using this command on a file, OdxSQL will prompt the user for the offsets and lengths of the data in the file.

ON INSTANCE instancenumber
Optional. Specify the instance on which to perform the flip. instancenumber is the integer instance number created when the connection to the Environment file was opened. If omitted, the current instance contained in the instance element of the Status array will be used. The INSTANCE keyword is optional. The ON keyword is required if the instance is specified.

WITH options
Optional. A comma separated list of options to apply to this command.

 

Options

 

 

Example

DATABASE | FILE | TABLE

DATABASE

The following example flips the entire Orders sample flat file database.

>connect orders.env

> flip database orders
Flipping 6 tables in database ORDERS
[1 of 6] CUSTOMERS - 999 rows required flipping.
[2 of 6] PRODUCTS - 99 rows required flipping.
[3 of 6] ACTIVITY - 6540 rows required flipping.
[4 of 6] CUST_NOTES - 259 rows required flipping.
[5 of 6] ORDERS - 10208 rows required flipping.
[6 of 6] INVENTORY - 204 rows required flipping.
All tables flipped

>

FILE

> export customer_no, company, licensee from customers where state='co' to colo.txt with delete
38 rows exported to colo.txt

> flip file colo.txt
Flipping file: C:\omnidex\colo.txt

OdxSQL prompts for the record length. This is 48, CUSTOMER_NO is a 4 byte integer, COMPANY is a 40 byte character string, and LICENSEE is a 4 byte integer.

Record length: 48

colo.txt is 1.8K and has 38 rows

OdxSQL the prompts for the Offset and length of the fields to be flipped. These are only the binary fields, therefore the length value specified can only be 2, 4 and 8. The offset must be determined, accounting for the space taken by the non-binary fields, as shown:

1) Offset: 0
1) Length: 4
2) Offset: 44
2) Length: 4
3) Offset:

38 rows flipped in colo.txt
>

An easier way to accomplish the same results would be to create an Omnidex Environment Catalog containing the table definition for the file, then use the FLIP TABLE command (see below).

TABLE

The following environment catalog entry defines the file used in the example above.

TABLE "COLO"
PHYSICAL "C:\omnidex\demodata\colo.txt"
PARENT KEY "CUSTOMER_NO"
COLUMN "CUSTOMER_NO" DATATYPE INTEGER LENGTH 4
COLUMN "COMPANY" DATATYPE CHAR LENGTH 40
COLUMN "LICENSEE" DATATYPE INTEGER LENGTH 4

Connect to the environment catalog containing this entry and run the FLIP TABLE command.

> flip table colo
38 COLO rows required flipping.
>

Top