groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike M <mike...@outlook.com>
Subject SQL: Bind variables in INSERT statement resulting in extra SELECT statement
Date Sat, 01 Aug 2020 06:29:24 GMT
A statement such as:
String qry = "INSERT INTO Author (firstname, lastname) VALUES ('$name', '$name')"
sql.execute qry

results in one database roundtrip, as one would expect.

Using bind variables such as this:
sql.execute "INSERT INTO Author (firstname, lastname) VALUES ($fname, $lname)"

results in 2 roundtrips (as visible in Wireshark):

  *   The INSERT statement, with the bind variables
  *   A subsequent SELECT firstname,lastname FROM Author

Is Groovy generating this second statement, or is it the JDBC driver? And why?
BTW: I suspect there is a where clause on the select, but I do not see it in the wireshark
capture.

Mime
View raw message