Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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