Monday, April 18, 2011

Oracle add new coloum in table with check existing

DECLARE
v_count NUMBER(1) := 0;
BEGIN
SELECT 1
INTO v_count
FROM USER_TAB_COLUMNS
WHERE lower(table_name) = 'cbcomm_dependent_gbl'
AND lower(column_name) = 'smoker';
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXECUTE IMMEDIATE 'alter table cbcomm_dependent_gbl add smoker1 NUMBER(1) NULL';
END;

No comments:

Post a Comment