Guest User

Untitled

a guest
Sep 22nd, 2015
12
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DELIMITER //
  2. CREATE PROCEDURE country_hos
  3. (IN requested_column_name CHAR(20), IN requested_referenced_table_name CHAR(20))
  4. BEGIN
  5.   SELECT DISTINCT TABLE_NAME
  6.   FROM information_schema.COLUMNS
  7.   WHERE (
  8.     table_schema = 'usa'
  9.     AND column_name = requested_column_name
  10.     AND TABLE_NAME NOT IN (SELECT TABLE_NAME FROM information_schema.key_column_usage WHERE referenced_table_name = requested_referenced_table_name AND table_schema = 'usa')
  11.     AND TABLE_NAME NOT IN (SELECT TABLE_NAME FROM information_schema.TABLES WHERE table_rows = 0 AND table_schema = 'usa'))
  12. END //
  13. DELIMITER ;
RAW Paste Data