Today's find:

Doing modulus to split digits: This is a simple query, worked well in 'SELECT' clause. But gave out error when Volatile table was created out of it:

A sample of SELECT that ran fine: **SELECT**

6789 a

,MOD((a/1000),10) (INT)** AS** BIT_POS1

, MOD((a/100),10) (INT)** AS** BIT_POS2

, MOD((a/10),10) (INT)** AS** BIT_POS3

, MOD(a,10) (INT)** AS** BIT_POS4;

Volatile table that gave out error: **CREATE**** VOLATILE**** TABLE** DIGIT_VT** AS**

( **SELECT**

6789 a

,MOD((a/1000),10) (INT)** AS** BIT_POS1

, MOD((a/100),10) (INT)** AS** BIT_POS2

, MOD((a/10),10) (INT)** AS** BIT_POS3

, MOD(a,10) (INT)** AS** BIT_POS4;

)** WITH**** DATA** **PRIMARY**** INDEX**(a) **ON**** COMMIT**** PRESERVE** ROWS;

Modified format: **CREATE**** VOLATILE**** TABLE** DIGIT_VT** AS**

( **SELECT**

6789 a

,((a/1000) MOD 10) (INT)** AS** BIT_POS1

,((a/100) MOD 10) (INT)** AS** BIT_POS2

,((a/10) MOD 10) (INT)** AS** BIT_POS3

,(a MOD 10) (INT)** AS** BIT_POS4

)** WITH**** DATA** **PRIMARY**** INDEX**(a) **ON**** COMMIT**** PRESERVE** ROWS;

Note: Method1 didn’t work when selected from derived table/subquery as well :(

~Meena

## No comments:

## Post a Comment