Wednesday, August 8, 2012

Find column type using built in function!!!


Find column type using built in function!!!

Did you know that datatype of column could be found  using a built in function called "TYPE" .

Till I came across this function, I used to follow the ancient method of digging into Data  Dictionaries(dbc.columns) to find the type of given column.

There are some cases in which people use CASE function to find the match for type of the column and based on which they do  execute steps.
E.g: 
 Check for column as timestamp , if yes extract date or so... 

To avoid usage of dbc.columns table , we can use Type(Column Name)  function

SELECT TYPE(TAB1.COL1);

Type(COL1)
-----------
INTEGER

No comments:

Post a Comment

Thank you :
- kareem