Insert data in bdm from a connector

Hello,
I’m trying to do a process with a MS SQL connector to insert data into my bdm. But I can’t find a good methode. I don’t want to use an ui interface because it must be something automatically. I’ve done a process with an input connector. But my question is if it’s correct putting in a script something like this "insert into myrequebdm (column1, column2,…) select col1, col2,… from msSQLtable " or is there other ways according the experience who has done something like that.

Thanks in advance for your ideas or comments.

Walter R.

Hi,

here you can see a very simple example of how to do such operation: https://community.bonitasoft.com/questions-and-answers/how-read-data-using-db-connector-business-variable

(look at the edit of the original question).

Best

Hi vitiellom,
it’s a very good example and starting point for my learning on this aspect.

Thanks very much.

Regards,

I’m trying anyway to assign the result of connector to a variable, at first, type java.util.list but when I run the process it gives me an error of methode about the variable used: “groovy.lang.MissingMethodException: No signature of method: java.util.ArrayList.next() is applicable for argument types: () values:
Possible solutions: get(int), get(int), set(int, java.lang.Object), set(int, java.lang.Object), wait(), sort()”.
I’m going to continue testing changing this variable but something is wrong with myvariable.next() loop.

I believe the exception is due to the fact that java ArrayList do not have a method next().
One way to iterate over the results returned by your query is to have a loop using the next() method on the resultset variable (which is of type java.sql.ResultSet).
Best

Hi vitiellom,
I’ve tried different methodes and finally I’ve put a ‘for’ instruction and it’s worked.
I don’t insist with this recipe but I ask myself if there is other methode not using an ‘entityDAO’, but using for example the initialisator when we have an input form style 'def myObject = new com.company.model.entity() and assign the list of my fieldlist to variables of entity. But well, it works.

Thanks again.

You can reference any variable you defined (you will find the available variables in the top-left dropdownlist) like this

def xyz = myVariable;

where myVariable is the name of the variable you want to use. You can then use the variable xyz in your script. It will have a set method for each field you defined that you can use to insert your external values.

Best