Created
December 14, 2009 16:56
-
-
Save clofresh/256211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- I want my code to be backwards compatible with database versions | |
SELECT COUNT(*) | |
INTO has_new_col | |
FROM all_tab_cols | |
WHERE table_name = 'UPDATED_TABLE' | |
AND column_name = 'NEW_COL'; | |
IF has_new_col = 0 THEN | |
INSERT INTO other_table | |
( | |
other_table_sid, | |
old_col | |
) | |
SELECT other_table_sid, | |
old_old | |
FROM updated_table; | |
ELSE | |
INSERT INTO other_table | |
( | |
other_table_sid, | |
old_col, | |
new_col | |
) | |
SELECT other_table_sid, | |
old_col, | |
new_col -- Gives PL/SQL: ORA-00904: "NEW_COL": invalid identifier :( | |
FROM updated_table; | |
END IF; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment