User Tools

Site Tools


create_table_as_select

CREATE TABLE AS SELECT...

By default Lure creates tables by using the CREATE TABLE statement in the table source file. In other words Lure does not make use of a patch file. You can override this default behaviour by creating a versioned patch file for the table. Lure will then execute the patch file and not attempt to create the table using the table source file.

To ensure that Lure executes this versioned patch file it is necessary to select the correct version number for the patch file:

The version number for the patch file must correspond to a version in the source code repository before the table source file was added for the first time.

To illustrate this let's consider the table with name DIVISION and Subversion as a source code repository. Firstly we must get the revision when the file DIVISION.table.lsql was first added to Subversion:

Using "svn log" to get the earliest revision

Since the first revision of the file DIVISION.table.lsql in the repository is 65, it will suffice if the version number of the versioned patch file is set to 64. (If the file has not yet been added to the Subversion repository then use the HEAD revision number.)

I will now create a patch file with name DIVISION.table.lsql.r64.lpatch and add my custom ”CREATE TABLE AS SELECT” statement:

Patch file with custom CREATE TABLE statement.

Use Lure Patch Test to confirm that the patch file correctly creates the table:

Patch Test output shows patch file is correct.

Lure executed the patch file and then verified that the patch file created a table with the correct structure.

create_table_as_select.txt · Last modified: 2013/07/31 14:49 by admin

Page Tools