alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

Backward-compatible SQL query against table with renamed and added column in SQL ?

Backward-compatible SQL query against table with renamed and added column in SQL ?

You can check if the colum exists and then run the appropriate `SELECT

 DECLARE
  v_column_exists number := 0;  
BEGIN
  Select count(*) into v_column_exists
    from user_tab_cols
    where upper(column_name) = 'b'
      and upper(table_name) = 't1';

  if (v_column_exists = 1) then
      execute immediate 'select a, b as c, null as d from t1';
  ELSE
      execute immediate 'select a, c, d from t2';
  end if;
end;
/

300 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online