Commit f78362f8 authored by Ajit Deshmukh's avatar Ajit Deshmukh

Updated ManageSqlConf source for updated logic of create function queries.

parent dde99e52
...@@ -1411,6 +1411,7 @@ public class ManageSqlConf extends ActionHandlerEJB ...@@ -1411,6 +1411,7 @@ public class ManageSqlConf extends ActionHandlerEJB
String createObjectType = getCreateObjectType(inputSql); String createObjectType = getCreateObjectType(inputSql);
boolean isCreateObject = createObjectType != null; boolean isCreateObject = createObjectType != null;
String objectName = isCreateObject ? extractObjectName(inputSql) : null; String objectName = isCreateObject ? extractObjectName(inputSql) : null;
System.out.println("objectName::: " + objectName);
/* ------------------------------- /* -------------------------------
* Execute per schema * Execute per schema
...@@ -1443,10 +1444,12 @@ public class ManageSqlConf extends ActionHandlerEJB ...@@ -1443,10 +1444,12 @@ public class ManageSqlConf extends ActionHandlerEJB
); );
} }
else if (rule.equals("SYN")) { else if (rule.equals("SYN")) {
System.out.println("objectName::: " + objectName+" schemaName::"+schemaName+" dbMain::"+dbMain);
String synonymSql = String synonymSql =
"CREATE SYNONYM " + schemaName + "." + objectName + "CREATE SYNONYM " + schemaName + "." + objectName +
" FOR " + dbMain + "." + objectName; " FOR " + dbMain + "." + objectName;
System.out.println("synonymSql::: " + synonymSql);
executeAndLog( executeAndLog(
schemaName, schemaName,
...@@ -1620,7 +1623,6 @@ public class ManageSqlConf extends ActionHandlerEJB ...@@ -1620,7 +1623,6 @@ public class ManageSqlConf extends ActionHandlerEJB
if (sql == null) return null; if (sql == null) return null;
// Normalize whitespace
String s = sql.replace("\n", " ") String s = sql.replace("\n", " ")
.replace("\t", " ") .replace("\t", " ")
.trim() .trim()
...@@ -1628,7 +1630,6 @@ public class ManageSqlConf extends ActionHandlerEJB ...@@ -1628,7 +1630,6 @@ public class ManageSqlConf extends ActionHandlerEJB
s = s.replaceAll("\\s+", " "); s = s.replaceAll("\\s+", " ");
// IMPORTANT: normalize CREATE OR REPLACE
if (s.startsWith("CREATE OR REPLACE")) { if (s.startsWith("CREATE OR REPLACE")) {
s = s.replaceFirst("CREATE\\s+OR\\s+REPLACE\\s+", "CREATE "); s = s.replaceFirst("CREATE\\s+OR\\s+REPLACE\\s+", "CREATE ");
} }
...@@ -1663,6 +1664,12 @@ public class ManageSqlConf extends ActionHandlerEJB ...@@ -1663,6 +1664,12 @@ public class ManageSqlConf extends ActionHandlerEJB
case "VIEW": case "VIEW":
keyword = "CREATE VIEW"; keyword = "CREATE VIEW";
break; break;
case "SYNONYM":
keyword = "CREATE SYNONYM";
break;
case "INDEX":
keyword = "CREATE INDEX";
break;
default: default:
return null; return null;
} }
...@@ -1672,18 +1679,23 @@ public class ManageSqlConf extends ActionHandlerEJB ...@@ -1672,18 +1679,23 @@ public class ManageSqlConf extends ActionHandlerEJB
String after = s.substring(idx + keyword.length()).trim(); String after = s.substring(idx + keyword.length()).trim();
// Remove schema if present (SCHEMA.OBJECT) if ("PACKAGE BODY".equals(objectType)) {
after = after.replaceFirst("^BODY\\s+", "");
}
if (after.contains(".")) { if (after.contains(".")) {
after = after.substring(after.indexOf(".") + 1); after = after.substring(after.indexOf(".") + 1);
} }
// Stop at first delimiter: space, (, AS, IS after = after.split("\\s|\\(|\\bAS\\b|\\bIS\\b|\\bFOR\\b|\\bON\\b", 2)[0].trim();
after = after.split("\\s|\\(|AS|IS", 2)[0].trim();
after = after.replaceAll("[^A-Z0-9_]", "").trim();
return after; return after;
} }
//Created a method to fetch the table name from provided SQL string by Ajit on 03-DEC-25 -- END //Created a method to fetch the table name from provided SQL string by Ajit on 03-DEC-25 -- END
//Created a method to add a placeholder before the table name which will be replaced by the schema name by Ajit on 03-DEC-25 -- START //Created a method to add a placeholder before the table name which will be replaced by the schema name by Ajit on 03-DEC-25 -- START
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment