Inserting NULL to Automatically Generate _id Values

When inserting a row into a table that has an _id column of type ObjectId, you can have the connector automatically generate a valid _id value for your new row. In connector versions 1.8.4 and earlier, you do this by specifying NULL as the _id value in your query statement.

In connector versions 2.0.0 and later, you do this by writing a query that does not specify an _id value. If you specify NULL, then the connector inserts NULL into the _id column.

Example

For example, a MongoDB database contains the following table named Boolean_Table:

_id Column1 KeyColumn

5a627dab3fc2394c4f824e94

0

false

Then, the following query is executed against Boolean_Table:

INSERT INTO Boolean_Table values (NULL, 1, 'true')

Connector versions 1.8.4 and earlier would insert a row into the table as shown below:

_id Column1 KeyColumn

5a627dab3fc2394c4f824e94

0

false

5a6a420c012857f7e7f69f78

1

true

Connector versions 2.0.0 and later would insert a row with a NULL _id value instead, as shown below:

_id Column1 KeyColumn

5a627dab3fc2394c4f824e94

0

false

 

1

true

To automatically generate an _id value using connector versions 2.0.0 and later, insert the row by executing the following query instead:

INSERT INTO Boolean_Table(Column1, KeyColumn) values (1, 'true')