I am having a problem while inserting records in table having parent child relationship using clover java api. My requirement is that, i need to insert records in table employee(empid, empname, empcode etc.) and Address( addressId, empID, streetaddress etc.). I am inserting records from a csv file.
I am creating two nodes of DBOutputTable and getting error of violating foreging key relationship . It is because of insertion is happening in Address table before insertion in parent table employee.
Can we have some syncronization in connected DBOutputTable nodes.
Hello,
you can use only one DBOutputTable with two queries, if you want to execute both queries for each record. Or you have to set higher phase number to the DBOutputTabla that inserts data to the child table.
I resolved the above problem by inserting a speed limiter between components. I am requiring some additional inputs on DBOutputTable component. Can I use sql functions as a sql statement in DBOutputTable. Actually, i need to insert and update the existing records of the table, but we can’t change the structure of the graph after its execution started. This decision I need to take dynamically as the data is transformed by the clover. I am using Reformat component where I am taking this decision, but I need to have two separate DBOutputTable node for insert and update query and on the basis of existence of record by doing a query lookup, I am selecting the particular node to execute its statement. Can we have both the queries in one single DBOutputTable component, and on the basis of existence of record we can execute only one sql query dynamically. I am doubtful if this behaviour is present in DBOutputTable so that we can execute a single sql statement from a bunch of queries given to DBOutputTable.
So I thought if I can have this decision making as a part of my sql functions, so that things would be much more easier.
Hello, I’m not sure if I’ve understood you well, but the simplest way to decide to which component to send the record is using return value in transform() function of Reformat, something like that:
function transform() {
if (my_condition){
transform0();
return 0;
}else{
transform1();
return 1;
}
where transform0() prepares records for one DBOutputTable and transform1() prepares them for the second one.