It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Insert multiple entries using Run and SQL Plugins

Does anyone have any suggestions on how to set up Bob Swift's Run & SQL plugins so that you can insert multiple lines into a MySQL DB, rather than running the plugin several times?

What I would like to do is set up a Run form where users can select multiple choices, each choice would represent 1 entry into the DB.

Example: A user needs to request an enhancement, which has multiple impacts to a business area. The form would have sections like so:

  • Request Number - Text - $req
  • Description of the request - Text Area - $desc
  • Business Area Affected - Select - $busarea
  • Impact on Business Area - Multiple select - $impact
    • Impact 1
    • Impact 2
    • Impact 3

Each entry into the DB represents 1 impact, so if the use selects more than one impact (3 in the case above), then there will be multiple entries into the DB.

With MySQL, I know I can write multiple Insert qeries, each seperated with a ";".

INSERT into Tbl_enhancements

(reqNBR, reqDESC, busAREA, IMPACT)


($req, $desc, $busarea, $impact);

How can I set up the SQL Plugin so it knows to use the INSERT query as many times as there are impacts?

Since the impact is represented by $impact in the Run Plugin, how do I differentiate between each entry?

Has anyone done this before?

Does anyone have some examples that they could share?

1 answer

1 accepted

There are a few ways to solve this. You need some sort of logic.

  1. Write an SQL function that takes the $impact as a parameter and figures out the inserts to run
  2. Write a small script (Scripting for Confluence) that implements logic to construct the SQL needed for 1 or more inserts. Then construct the wiki markup for the sql macro with the constructed SQL and evaluate it. Use the same logic techniques as How to generate choice values using SQL
  3. Similar to 2, but just loop of each selection and run the sql for just a single statement.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Apr 03, 2019 in Marketplace Apps

How to estimate projects more accurately?

Gaining insight into your team’s effectiveness and choosing the right estimation technique.   Estimating projects is hard. It is because people have the tendency to underestimate the time thin...

274 views 2 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you