Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Component Sharing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gagandeep Singh Bhatia
Component Sharing
Commits
c3ed72b9
Commit
c3ed72b9
authored
Jan 02, 2026
by
Ajit Deshmukh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated the condition to apply the placeholder on create function query.
parent
f78362f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
220 additions
and
49 deletions
+220
-49
Ajit/Manage SQL/Manage SQL/ManageSqlConf.java
Ajit/Manage SQL/Manage SQL/ManageSqlConf.java
+220
-49
No files found.
Ajit/Manage SQL/Manage SQL/ManageSqlConf.java
View file @
c3ed72b9
...
@@ -1374,30 +1374,54 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1374,30 +1374,54 @@ public class ManageSqlConf extends ActionHandlerEJB
//Created a method to execute the SQL in the schemas stored in the Enterprise table for the provided enterprise value by Ajit on 03-DEC-25 -- START
//Created a method to execute the SQL in the schemas stored in the Enterprise table for the provided enterprise value by Ajit on 03-DEC-25 -- START
public
void
processSqlForEnterprise
(
Connection
conn
,
String
enterpriseCode
,
String
inputSql
,
String
tranId
,
String
linNo
,
String
requestID
,
String
userId
,
String
chgTerm
)
throws
Exception
{
public
void
processSqlForEnterprise
(
Connection
conn
,
String
enterpriseCode
,
String
inputSql
,
String
tranId
,
String
linNo
,
String
requestID
,
String
userId
,
String
chgTerm
)
throws
Exception
{
inputSql
=
injectSchemaPlaceholder
(
inputSql
);
inputSql
=
injectSchemaPlaceholder
(
inputSql
);
System
.
out
.
println
(
"inputSql
lklklk ::::::::>>>>>
"
+
inputSql
);
System
.
out
.
println
(
"inputSql
:::::>>>><<<<<
"
+
inputSql
);
/* -------------------------------
/* -------------------------------
* Fetch schemas
* Fetch schemas
* ------------------------------- */
* ------------------------------- */
String
query
=
"SELECT DB_DEV, DB_MAIN, DB_READ, DB_PILOT FROM enterprise WHERE enterprise = ?"
;
String
query
=
PreparedStatement
ps
=
conn
.
prepareStatement
(
query
);
"SELECT DB_DEV, DB_MAIN, DB_READ, DB_PILOT "
+
ps
.
setString
(
1
,
enterpriseCode
);
"FROM enterprise WHERE enterprise = ?"
;
ResultSet
rs
=
ps
.
executeQuery
();
if
(!
rs
.
next
())
{
String
dbDev
,
dbMain
,
dbRead
,
dbPilot
;
throw
new
Exception
(
"No enterprise found for: "
+
enterpriseCode
);
try
(
PreparedStatement
ps
=
conn
.
prepareStatement
(
query
))
{
ps
.
setString
(
1
,
enterpriseCode
);
try
(
ResultSet
rs
=
ps
.
executeQuery
())
{
if
(!
rs
.
next
())
{
throw
new
Exception
(
"No enterprise found for: "
+
enterpriseCode
);
}
dbDev
=
rs
.
getString
(
"DB_DEV"
);
dbMain
=
rs
.
getString
(
"DB_MAIN"
);
dbRead
=
rs
.
getString
(
"DB_READ"
);
dbPilot
=
rs
.
getString
(
"DB_PILOT"
);
}
}
}
String
dbDev
=
rs
.
getString
(
"DB_DEV"
);
/* -------------------------------
String
dbMain
=
rs
.
getString
(
"DB_MAIN"
);
* Get CURRENT_USER
String
dbRead
=
rs
.
getString
(
"DB_READ"
);
* ------------------------------- */
String
dbPilot
=
rs
.
getString
(
"DB_PILOT"
);
String
currentUser
;
try
(
PreparedStatement
ps
=
conn
.
prepareStatement
(
"SELECT USER FROM DUAL"
);
ResultSet
rs
=
ps
.
executeQuery
())
{
rs
.
close
();
rs
.
next
();
ps
.
close
();
currentUser
=
rs
.
getString
(
1
);
}
System
.
out
.
println
(
"CURRENT_USER ::: "
+
currentUser
);
/* -------------------------------
/* -------------------------------
* Schema execution rules
* Schema execution rules
...
@@ -1411,7 +1435,9 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1411,7 +1435,9 @@ 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
);
System
.
out
.
println
(
"objectName ::: "
+
objectName
);
System
.
out
.
println
(
"createObjectType ::: "
+
createObjectType
);
/* -------------------------------
/* -------------------------------
* Execute per schema
* Execute per schema
...
@@ -1429,7 +1455,8 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1429,7 +1455,8 @@ public class ManageSqlConf extends ActionHandlerEJB
* ===================================== */
* ===================================== */
if
(
isCreateObject
)
{
if
(
isCreateObject
)
{
if
(
rule
.
equals
(
"ALL"
))
{
if
(
"ALL"
.
equals
(
rule
))
{
executeAndLog
(
executeAndLog
(
schemaName
,
schemaName
,
inputSql
,
inputSql
,
...
@@ -1442,17 +1469,26 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1442,17 +1469,26 @@ public class ManageSqlConf extends ActionHandlerEJB
dbMain
,
dbMain
,
true
true
);
);
}
else
if
(
rule
.
equals
(
"SYN"
))
{
System
.
out
.
println
(
"objectName::: "
+
objectName
+
" schemaName::"
+
schemaName
+
" dbMain::"
+
dbMain
);
}
else
if
(
"SYN"
.
equals
(
rule
))
{
// Skip synonym & grant if CURRENT_USER is owner
if
(
currentUser
.
equalsIgnoreCase
(
dbMain
))
{
System
.
out
.
println
(
"Skipping SYN. CURRENT_USER is DB_MAIN."
);
continue
;
}
/* -----------------------------
* Create synonym in CURRENT_USER
* ----------------------------- */
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
,
synonymSql
,
synonymSql
,
tranId
,
tranId
,
enterpriseCode
,
enterpriseCode
,
...
@@ -1464,12 +1500,27 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1464,12 +1500,27 @@ public class ManageSqlConf extends ActionHandlerEJB
false
false
);
);
/* -----------------------------
* Grant based on object type
* ----------------------------- */
String
grantSql
=
null
;
String
grantSql
=
null
;
if
(
schemaName
.
equals
(
dbRead
))
{
if
(
"TABLE"
.
equalsIgnoreCase
(
createObjectType
)
grantSql
=
"GRANT SELECT ON "
+
dbMain
+
"."
+
objectName
+
" TO "
+
dbRead
;
||
"VIEW"
.
equalsIgnoreCase
(
createObjectType
)
}
else
if
(
schemaName
.
equals
(
dbPilot
))
{
||
"SEQUENCE"
.
equalsIgnoreCase
(
createObjectType
))
{
grantSql
=
"GRANT EXECUTE ON "
+
dbMain
+
"."
+
objectName
+
" TO "
+
dbPilot
;
grantSql
=
"GRANT SELECT ON "
+
dbMain
+
"."
+
objectName
+
" TO "
+
schemaName
;
}
else
if
(
"PROCEDURE"
.
equalsIgnoreCase
(
createObjectType
)
||
"FUNCTION"
.
equalsIgnoreCase
(
createObjectType
)
||
"PACKAGE"
.
equalsIgnoreCase
(
createObjectType
)
||
"TYPE"
.
equalsIgnoreCase
(
createObjectType
))
{
grantSql
=
"GRANT EXECUTE ON "
+
dbMain
+
"."
+
objectName
+
" TO "
+
schemaName
;
}
}
if
(
grantSql
!=
null
)
{
if
(
grantSql
!=
null
)
{
...
@@ -1488,14 +1539,16 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1488,14 +1539,16 @@ public class ManageSqlConf extends ActionHandlerEJB
}
}
}
}
continue
;
//
s
kip DML flow
continue
;
//
S
kip DML flow
}
}
/* =====================================
/* =====================================
* INSERT / UPDATE / DELETE FLOW
* INSERT / UPDATE / DELETE FLOW
* ===================================== */
* ===================================== */
if
(
rule
.
equals
(
"SYN"
))
{
if
(
"SYN"
.
equals
(
rule
))
{
System
.
out
.
println
(
"Skipping SQL for schema (only SYN allowed): "
+
schemaName
);
System
.
out
.
println
(
"Skipping DML for SYN-only schema: "
+
schemaName
);
continue
;
continue
;
}
}
...
@@ -1516,6 +1569,7 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1516,6 +1569,7 @@ public class ManageSqlConf extends ActionHandlerEJB
System
.
out
.
println
(
"Execution completed successfully."
);
System
.
out
.
println
(
"Execution completed successfully."
);
}
}
//Created a method to execute the SQL in the schemas stored in the Enterprise table for the provided enterprise value by Ajit on 03-DEC-25 -- END
//Created a method to execute the SQL in the schemas stored in the Enterprise table for the provided enterprise value by Ajit on 03-DEC-25 -- END
...
@@ -1532,20 +1586,72 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1532,20 +1586,72 @@ public class ManageSqlConf extends ActionHandlerEJB
boolean
rethrow
boolean
rethrow
)
throws
Exception
{
)
throws
Exception
{
Connection
conn
=
null
;
Connection
conn
=
null
;
Connection
connForDml
=
null
;
Connection
connForQueryExec
=
null
;
ConnDriver
connDriver
=
new
ConnDriver
();
ConnDriver
connDriver
=
new
ConnDriver
();
conn
=
connDriver
.
getConnectDB
(
schemaName
);
ConnDriver
connDriver1
=
new
ConnDriver
();
String
connForExec
=
""
;
String
finalSql
=
applySchema
(
inputSql
,
schemaName
);
String
finalSql
=
applySchema
(
inputSql
,
schemaName
);
finalSql
=
finalSql
.
replace
(
"\n"
,
" "
)
.
replace
(
"\r"
,
" "
)
.
replaceAll
(
"\\s+"
,
" "
)
.
trim
();
System
.
out
.
println
(
">>> EXECUTING SQL <<<<>>> "
+
finalSql
);
System
.
out
.
println
(
"finalSql:: "
+
finalSql
);
System
.
out
.
println
(
"finalSql:: "
+
finalSql
);
System
.
out
.
println
(
"schemaName:: "
+
schemaName
);
System
.
out
.
println
(
"schemaName:: "
+
schemaName
);
System
.
out
.
println
(
"dbMainSchema:: "
+
dbMainSchema
);
System
.
out
.
println
(
"enterpriseCode:: "
+
enterpriseCode
);
int
updCount
=
0
;
String
execSchema
=
schemaName
;
String
error
=
null
;
try
(
Statement
stmt
=
conn
.
createStatement
())
{
String
sqlUpper
=
finalSql
.
trim
().
toUpperCase
();
updCount
=
stmt
.
executeUpdate
(
finalSql
);
if
(
sqlUpper
.
startsWith
(
"CREATE SYNONYM"
)
||
sqlUpper
.
startsWith
(
"GRANT SELECT ON"
)
||
sqlUpper
.
startsWith
(
"GRANT EXECUTE ON"
))
{
execSchema
=
dbMainSchema
;
}
System
.
out
.
println
(
"execSchema:: "
+
execSchema
);
System
.
out
.
println
(
"enterpriseCode:: "
+
enterpriseCode
);
conn
=
connDriver1
.
getConnectDB
(
enterpriseCode
);
//connForDml = connDriverForDml.getConnectDB(schemaName);
String
connForExecSql
=
"select schema_name from enterprise where enterprise = ?"
;
PreparedStatement
connForExecPstmt
=
conn
.
prepareStatement
(
connForExecSql
);
connForExecPstmt
.
setString
(
1
,
enterpriseCode
);
ResultSet
connForExecRs
=
connForExecPstmt
.
executeQuery
();
while
(
connForExecRs
.
next
())
{
connForExec
=
connForExecRs
.
getString
(
"schema_name"
);
}
System
.
out
.
println
(
"connForExec:: "
+
connForExec
);
connForQueryExec
=
connDriver
.
getConnectDB
(
connForExec
);
int
updCount
=
0
;
String
error
=
null
;
conn
.
commit
();
try
{
if
(
isTrigger
(
finalSql
)
||
isDdl
(
finalSql
))
{
// Use Statement for DDL / trigger
Statement
stmt
=
connForQueryExec
.
createStatement
();
stmt
.
execute
(
finalSql
);
}
else
{
// ✅ INSERT / UPDATE / DELETE
Statement
stmt
=
connForQueryExec
.
createStatement
();
updCount
=
stmt
.
executeUpdate
(
finalSql
);
connForQueryExec
.
commit
();
}
logSqlExecution
(
logSqlExecution
(
tranId
,
enterpriseCode
,
linNo
,
requestID
,
tranId
,
enterpriseCode
,
linNo
,
requestID
,
finalSql
,
updCount
,
"C"
,
userId
,
chgTerm
,
null
,
dbMainSchema
finalSql
,
updCount
,
"C"
,
userId
,
chgTerm
,
null
,
dbMainSchema
...
@@ -1554,8 +1660,8 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1554,8 +1660,8 @@ public class ManageSqlConf extends ActionHandlerEJB
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
try
{
try
{
conn
.
rollback
();
if
(
connForQueryExec
!=
null
)
connForQueryExec
.
rollback
();
}
catch
(
SQLException
e1
)
{
}
catch
(
SQLException
e1
)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
e1
.
printStackTrace
();
e1
.
printStackTrace
();
}
}
...
@@ -1569,9 +1675,29 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1569,9 +1675,29 @@ public class ManageSqlConf extends ActionHandlerEJB
if
(
rethrow
)
{
if
(
rethrow
)
{
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
}
finally
{
if
(
connForExecRs
!=
null
)
connForExecRs
.
close
();
if
(
connForExecPstmt
!=
null
)
connForExecPstmt
.
close
();
if
(
connForQueryExec
!=
null
)
connForQueryExec
.
close
();
if
(
conn
!=
null
)
conn
.
close
();
}
}
}
private
boolean
isDdl
(
String
sql
)
{
String
s
=
sql
.
trim
().
toUpperCase
();
return
s
.
startsWith
(
"CREATE"
)
||
s
.
startsWith
(
"ALTER"
)
||
s
.
startsWith
(
"DROP"
)
||
s
.
startsWith
(
"GRANT"
)
||
s
.
startsWith
(
"EXECUTE"
)
||
s
.
startsWith
(
"REVOKE"
);
}
}
private
boolean
isTrigger
(
String
sql
)
{
return
sql
.
trim
().
toUpperCase
().
startsWith
(
"CREATE"
)
&&
sql
.
toUpperCase
().
contains
(
" TRIGGER "
);
}
private
void
logSqlExecution
(
private
void
logSqlExecution
(
String
tranId
,
String
tranId
,
...
@@ -1620,9 +1746,9 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1620,9 +1746,9 @@ public class ManageSqlConf extends ActionHandlerEJB
//Created a method to fetch the table name from provided SQL string by Ajit on 03-DEC-25 -- START
//Created a method to fetch the table name from provided SQL string by Ajit on 03-DEC-25 -- START
private
String
extractObjectName
(
String
sql
)
{
private
String
extractObjectName
(
String
sql
)
{
System
.
out
.
println
(
"extractObjectName SQL::::::: "
+
sql
);
if
(
sql
==
null
)
return
null
;
if
(
sql
==
null
)
return
null
;
sql
=
removeComments
(
sql
);
String
s
=
sql
.
replace
(
"\n"
,
" "
)
String
s
=
sql
.
replace
(
"\n"
,
" "
)
.
replace
(
"\t"
,
" "
)
.
replace
(
"\t"
,
" "
)
.
trim
()
.
trim
()
...
@@ -1670,6 +1796,9 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1670,6 +1796,9 @@ public class ManageSqlConf extends ActionHandlerEJB
case
"INDEX"
:
case
"INDEX"
:
keyword
=
"CREATE INDEX"
;
keyword
=
"CREATE INDEX"
;
break
;
break
;
case
"TRIGGER"
:
keyword
=
"CREATE TRIGGER"
;
break
;
default
:
default
:
return
null
;
return
null
;
}
}
...
@@ -1687,7 +1816,11 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1687,7 +1816,11 @@ public class ManageSqlConf extends ActionHandlerEJB
after
=
after
.
substring
(
after
.
indexOf
(
"."
)
+
1
);
after
=
after
.
substring
(
after
.
indexOf
(
"."
)
+
1
);
}
}
after
=
after
.
split
(
"\\s|\\(|\\bAS\\b|\\bIS\\b|\\bFOR\\b|\\bON\\b"
,
2
)[
0
].
trim
();
after
=
after
.
split
(
"\\s|\\("
,
2
)[
0
].
trim
();
after
=
after
.
replaceAll
(
"[^A-Z0-9_]"
,
""
).
trim
();
after
=
after
.
replaceAll
(
"[^A-Z0-9_]"
,
""
).
trim
();
...
@@ -1707,7 +1840,30 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1707,7 +1840,30 @@ public class ManageSqlConf extends ActionHandlerEJB
if
(
s
.
toUpperCase
().
startsWith
(
"CREATE SYNONYM"
))
{
if
(
s
.
toUpperCase
().
startsWith
(
"CREATE SYNONYM"
))
{
return
sql
;
return
sql
;
}
}
// CREATE OR REPLACE VIEW view_name
s
=
s
.
replaceAll
(
"(?i)CREATE\\s+OR\\s+REPLACE\\s+VIEW\\s+(?!\\{SCHEMA\\}|[A-Z0-9_]+\\.)"
,
"CREATE OR REPLACE VIEW {SCHEMA}."
);
// 1️⃣ PACKAGE BODY (FIRST)
s
=
s
.
replaceAll
(
"(?i)CREATE\\s+OR\\s+REPLACE\\s+PACKAGE\\s+BODY\\s+(?![A-Z0-9_]+\\.)"
,
"CREATE OR REPLACE PACKAGE BODY {SCHEMA}."
);
// 2️⃣ PACKAGE (EXCLUDE BODY)
s
=
s
.
replaceAll
(
"(?i)CREATE\\s+OR\\s+REPLACE\\s+PACKAGE\\s+(?!BODY\\s+)(?![A-Z0-9_]+\\.)"
,
"CREATE OR REPLACE PACKAGE {SCHEMA}."
);
// TRIGGER: ON table
s
=
s
.
replaceAll
(
"(?i)ON\\s+(?!\\{SCHEMA\\}|[A-Z0-9_]+\\.)"
,
"ON {SCHEMA}."
);
// INSERT INTO table
// INSERT INTO table
s
=
s
.
replaceAll
(
s
=
s
.
replaceAll
(
"(?i)INSERT\\s+INTO\\s+(?!\\{SCHEMA\\}|[A-Z0-9_]+\\.)"
,
"(?i)INSERT\\s+INTO\\s+(?!\\{SCHEMA\\}|[A-Z0-9_]+\\.)"
,
...
@@ -1732,6 +1888,9 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1732,6 +1888,9 @@ public class ManageSqlConf extends ActionHandlerEJB
"FROM {SCHEMA}."
"FROM {SCHEMA}."
);
);
return
s
;
return
s
;
}
}
...
@@ -1757,7 +1916,7 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1757,7 +1916,7 @@ public class ManageSqlConf extends ActionHandlerEJB
if
(
s
.
startsWith
(
"CREATE PACKAGE BODY"
))
return
"PACKAGE BODY"
;
if
(
s
.
startsWith
(
"CREATE PACKAGE BODY"
))
return
"PACKAGE BODY"
;
if
(
s
.
startsWith
(
"CREATE PACKAGE"
))
return
"PACKAGE"
;
if
(
s
.
startsWith
(
"CREATE PACKAGE"
))
return
"PACKAGE"
;
if
(
s
.
startsWith
(
"CREATE VIEW"
))
return
"VIEW"
;
if
(
s
.
startsWith
(
"CREATE VIEW"
))
return
"VIEW"
;
if
(
s
.
startsWith
(
"CREATE TRIGGER"
))
return
"TRIGGER"
;
return
null
;
return
null
;
}
}
...
@@ -1770,6 +1929,7 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1770,6 +1929,7 @@ public class ManageSqlConf extends ActionHandlerEJB
// Replace placeholder first (DML)
// Replace placeholder first (DML)
if
(
s
.
contains
(
"{SCHEMA}"
))
{
if
(
s
.
contains
(
"{SCHEMA}"
))
{
s
=
s
.
replace
(
"{SCHEMA}"
,
schema
);
s
=
s
.
replace
(
"{SCHEMA}"
,
schema
);
return
s
;
}
}
// CREATE TABLE
// CREATE TABLE
...
@@ -1812,6 +1972,14 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1812,6 +1972,14 @@ public class ManageSqlConf extends ActionHandlerEJB
);
);
}
}
// CREATE PACKAGE BODY
if
(
s
.
matches
(
"(?is)^CREATE\\s+(OR\\s+REPLACE\\s+)?PACKAGE\\s+BODY\\s+.*"
))
{
return
s
.
replaceFirst
(
"(?is)CREATE\\s+(OR\\s+REPLACE\\s+)?PACKAGE\\s+BODY\\s+"
,
"CREATE OR REPLACE PACKAGE BODY "
+
schema
+
"."
);
}
// CREATE PACKAGE
// CREATE PACKAGE
if
(
s
.
matches
(
"(?is)^CREATE\\s+(OR\\s+REPLACE\\s+)?PACKAGE\\s+.*"
))
{
if
(
s
.
matches
(
"(?is)^CREATE\\s+(OR\\s+REPLACE\\s+)?PACKAGE\\s+.*"
))
{
return
s
.
replaceFirst
(
return
s
.
replaceFirst
(
...
@@ -1820,13 +1988,7 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1820,13 +1988,7 @@ public class ManageSqlConf extends ActionHandlerEJB
);
);
}
}
// CREATE PACKAGE BODY
if
(
s
.
matches
(
"(?is)^CREATE\\s+(OR\\s+REPLACE\\s+)?PACKAGE\\s+BODY\\s+.*"
))
{
return
s
.
replaceFirst
(
"(?is)CREATE\\s+(OR\\s+REPLACE\\s+)?PACKAGE\\s+BODY\\s+"
,
"CREATE OR REPLACE PACKAGE BODY "
+
schema
+
"."
);
}
// CREATE TYPE
// CREATE TYPE
if
(
s
.
matches
(
"(?is)^CREATE\\s+(OR\\s+REPLACE\\s+)?TYPE\\s+.*"
))
{
if
(
s
.
matches
(
"(?is)^CREATE\\s+(OR\\s+REPLACE\\s+)?TYPE\\s+.*"
))
{
...
@@ -1840,6 +2002,15 @@ public class ManageSqlConf extends ActionHandlerEJB
...
@@ -1840,6 +2002,15 @@ public class ManageSqlConf extends ActionHandlerEJB
}
}
private
String
removeComments
(
String
sql
)
{
// Remove /* ... */ comments
sql
=
sql
.
replaceAll
(
"(?s)/\\*.*?\\*/"
,
" "
);
// Remove -- comments
sql
=
sql
.
replaceAll
(
"(?m)--.*?$"
,
" "
);
return
sql
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment