Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

call MISMATCH_PROC();

CREATE or replace TABLE EMP_SOURCE(ID NUMBER,


NAME VARCHAR);

CREATE or replace TABLE EMP_TARGET(ID NUMBER,


NAME VARCHAR,
CITY VARCHAR);
CREATE OR REPLACE PROCEDURE MISMATCH_PROC()
RETURNS STRING
LANGUAGE SQL
AS
$$
DECLARE
l_source_col_count NUMBER;
l_target_col_count NUMBER;
l_mismatch_col_count NUMBER;

BEGIN
----source count
select count(*)
into l_source_col_count
from information_schema.columns
where table_schema = 'TRG'
and table_name = 'EMP_SOURCE';

select count(*)
into l_target_col_count
from information_schema.columns
where table_schema = 'TRG'
and table_name = 'EMP_TARGET';

--1ST validation source and target table count


IF (l_source_col_count = l_target_col_count) THEN
RETURN 'Source and Target Column Count Matches';
ELSE
l_mismatch_col_count :=abs(l_source_col_count - l_target_col_count) ;
RETURN l_mismatch_col_count;
END IF;

END;
$$;

You might also like