Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Gomes da Silva committed Sep 24, 2019
2 parents f16e266 + 8a6e397 commit dfbfab0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.clagomess</groupId>
<artifactId>mod-plsql</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>

<properties>
<jetty.version>9.4.19.v20190610</jetty.version>
Expand Down
20 changes: 15 additions & 5 deletions src/main/java/com/github/clagomess/modplsql/jdbc/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public static void init(ConfigDto dto) throws SQLException {
}

public static String runPl(String plName, Map<String, String> param) throws SQLException {
int idx;

// fill parans
param.putAll(configDto.getParamsAsMap());

Expand All @@ -45,10 +47,10 @@ public static String runPl(String plName, Map<String, String> param) throws SQLE

sql.append(String.format(" NUM_ENTRIES := %s;\n", param.size()));

int idx = 1;
idx = 1;
for (Map.Entry<String, String> entry : param.entrySet()) {
sql.append(String.format(" NAME_ARRAY(%s) := '%s';\n", idx, entry.getKey()));
sql.append(String.format(" VALUE_ARRAY(%s) := '%s';\n", idx, escape(entry.getValue())));
sql.append(String.format(" NAME_ARRAY(%s) := ?; -- '%s'\n", idx, entry.getKey()));
sql.append(String.format(" VALUE_ARRAY(%s) := ?; -- '%s'\n", idx, escape(entry.getValue())));
idx++;
}

Expand All @@ -63,9 +65,17 @@ public static String runPl(String plName, Map<String, String> param) throws SQLE

log.info("QUERY:\n{}", sql.toString());

stmt.executeUpdate(sql.toString());
PreparedStatement pstmt = conn.prepareStatement(sql.toString());
idx = 1;
for (Map.Entry<String, String> entry : param.entrySet()) {
pstmt.setString(idx, entry.getKey());
idx++;
pstmt.setString(idx, entry.getValue());
idx++;
}

pstmt.execute();

log.info("GET RESULT");
return getResult();
}

Expand Down

0 comments on commit dfbfab0

Please sign in to comment.