Skip to content

Commit

Permalink
fix(schema): failed to query variables on native oracle (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
yhilmare authored Jun 5, 2024
1 parent 5b40a4c commit 15d620a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public String getConnectionId(Connection connection) {

@Override
public String getVariable(@NonNull Connection connection, @NonNull String variableName) {
String querySql = "SELECT VALUE FROM SYS.V$PARAMETER WHERE NAME = '" + variableName.toLowerCase() + "'";
String querySql = "SELECT VALUE FROM V$PARAMETER WHERE NAME = '" + variableName.toLowerCase() + "'";
String value = null;
try {
value = JdbcOperationsUtil.getJdbcOperations(connection).queryForObject(querySql, String.class);
Expand All @@ -78,7 +78,7 @@ public String getVariable(@NonNull Connection connection, @NonNull String variab
* nls parameters maybe null in V$PARAMETER, we need to query from V$NLS_PARAMETERS
*/
if (Objects.isNull(value) && variableName.toLowerCase().startsWith("nls_")) {
querySql = "SELECT VALUE FROM SYS.V$NLS_PARAMETERS WHERE PARAMETER = '" + variableName.toUpperCase() + "'";
querySql = "SELECT VALUE FROM V$NLS_PARAMETERS WHERE PARAMETER = '" + variableName.toUpperCase() + "'";
try {
value = JdbcOperationsUtil.getJdbcOperations(connection).queryForObject(querySql, String.class);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public SqlExecTime getExecuteDetail(Statement statement, String version) throws
SqlExecTime sqlExecTime = new SqlExecTime();
try {
String sql =
"SELECT PREV_SQL_ID FROM SYS.V$SESSION WHERE SID = SYS_CONTEXT('USERENV', 'SID') and AUDSID=SYS_CONTEXT('USERENV', 'SESSIONID')";
"SELECT PREV_SQL_ID FROM V$SESSION WHERE SID = SYS_CONTEXT('USERENV', 'SID') and AUDSID=SYS_CONTEXT('USERENV', 'SESSIONID')";
String preSqlId = null;
ResultSet rs = statement.executeQuery(sql);
while (rs.next()) {
preSqlId = rs.getString("PREV_SQL_ID");
}
Validate.notNull(preSqlId, "PREV_SQL_ID can not be null");
sql = "select SQL_TEXT, ELAPSED_TIME, LAST_ACTIVE_TIME FROM SYS.V$SQL WHERE SQL_ID='" + preSqlId
sql = "select SQL_TEXT, ELAPSED_TIME, LAST_ACTIVE_TIME FROM V$SQL WHERE SQL_ID='" + preSqlId
+ "' ORDER BY LAST_ACTIVE_TIME DESC";
ResultSet resultSet = statement.executeQuery(sql);
if (resultSet.next()) {
Expand Down

0 comments on commit 15d620a

Please sign in to comment.