Saturday, June 18, 2016

Why Target instance name is not shown in Publication LOV?

Many times, in CZGOLD instance environment, it is observed that cloned CZGOLD instance will not show cloned target instance while creating publication. Configurator uses below query to check if the remote instance should be visible in Publication LOV or not. You can check data based on this and correct as required.

In simple words, in cloned target instance's cz_servers table, if any server is having source_server_flag as 1, then that server's name in target must match with CZ instance's LOCAL server name. If there are multiple records with source_server_flag as 1, then it might create issue as well.

SELECT local_name, server_local_id
  FROM cz_servers
 WHERE server_local_id >= 0
   AND cz_model_migration_pvt.target_open_for ('P', fndnam_link_name, local_name)='1'


FUNCTION target_open_for (
   p_migration_or_publishing   IN   VARCHAR2,
   p_link_name                 IN   VARCHAR2,
   p_local_name                IN   VARCHAR2
)  RETURN VARCHAR2
IS
   target_open            VARCHAR2 (1)    := '1';
   target_not_open        VARCHAR2 (1)    := '0';
   l_source_server_flag           VARCHAR2 (1);
   l_source_server_flag_for_pub   VARCHAR2 (1);
   l_sql_str              VARCHAR2 (2000);
   l_sql_str_for_pub      VARCHAR2 (2000);
   target_instance_for_pub VARCHAR2(2000);
   local_instance_name VARCHAR2(2000);

BEGIN

   IF (p_migration_or_publishing = MODE_PUBLICATION) THEN
       IF (p_local_name='LOCAL') THEN
         RETURN target_open;
       END IF;
   END IF;

   IF p_link_name IS NULL THEN
      RETURN target_not_open;
   END IF;

   l_sql_str :=
         'SELECT NVL(source_server_flag,''0''), local_name FROM cz_servers@' || p_link_name || ' ' ||
         'WHERE source_server_flag = ''1'' ';

   EXECUTE IMMEDIATE l_sql_str
                INTO l_source_server_flag, target_instance_for_pub;


   IF (p_migration_or_publishing = MODE_PUBLICATION) THEN

      SELECT instance_name
       INTO local_instance_name
      FROM cz_servers
       WHERE local_name = 'LOCAL';

       IF (local_instance_name=target_instance_for_pub) THEN
         RETURN target_open;
       END IF;
   END IF;

   RETURN target_not_open;

EXCEPTION
   WHEN NO_DATA_FOUND THEN
      RETURN target_open;
   WHEN OTHERS THEN
      RETURN target_not_open;
END;