LucidDbAppLib GENERATE CRC
From Eigenpedia
Contents |
Syntax
SELECT * FROM TABLE(
APPLIB.GENERATE_CRC (
CURSOR ( sql_query ) ) )
SELECT * FROM TABLE(
APPLIB.GENERATE_CRC (
CURSOR ( sql_query ),
ROW ( columnA, columnB, ...),
exclude ) )
GENERATE_CRC is a UDX, which must be invoked in the FROM clause of a SQL query.
Purpose
Generates the CRC value per row for input table resulting from sql_query.
Returns a table with all columns specified by sql_query and an additional column CRC_VALUE, which is the crc value calculated from the columns specified by sql_query and filtered by the subset of rows if they are passed in. CRC_VALUE is of type BIGINT.
Parameters
- sql_query: sql query that specifies the input table which CRC values will be calculated for
- row (columnA, columnB, ...): one row of column names. If exclude is false then columns in the row are used to calculate CRC, if exclude is true, then all columns except the columns in the row are used to calculate CRC. If row is not specified, then all columns will be used to calculate the CRC.
- exclude: boolean value specifying whether to include or exclude columns in row
Examples
SELECT * FROM TABLE( APPLIB.GENERATE_CRC( CURSOR( select * from MYTABLE ) ) )
| COLUMN_A | COLUMN_B |
|---|---|
| 1 | One |
| 2 | Two |
| 3 | Three |
RETURNS:
| COLUMN_A | COLUMN_B | CRC_VALUE |
|---|---|---|
| 1 | One | 3568523739 |
| 2 | Two | 2913008290 |
| 3 | Three | 1913312332 |
SELECT * FROM TABLE( APPLIB.GENERATE_CRC( CURSOR( select * from MYTABLE ), ROW( COLUMN_B ), false ) )
RETURNS:
| COLUMN_A | COLUMN_B | CRC_VALUE |
|---|---|---|
| 1 | One | 1109508113 |
| 2 | Two | 696765574 |
| 3 | Three | 2265249777 |

