cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to insert the values in infotable as a whole in to the external database tables ?

Highlighted
Regular Member

How to insert the values in infotable as a whole in to the external database tables ?

Hello ,

I am able to upload a CSV file into the platform and able to make those values in CSV file to store in a infotable in thingworx platform.

 

But from there I should insert the values into a table that exists in the external database like postgres .

I had gone through the community but I did'nt find any solution.

Can someone please help me out .

 

Regards,

Bhargav.

4 REPLIES 4
Highlighted

Re: How to insert the values in infotable as a whole in to the external database tables ?

Highlighted

Re: How to insert the values in infotable as a whole in to the external database tables ?

@Bhargav1  

I just wanted to follow up to see if previous response was helpful for your question?

 

If so, please indicate the appropriate response as the Accepted Solution for the benefit of other Community members who have the same question. If you are still experiencing issues, please do let us know your questions or concerns.

 

Thanks,

Vibhuti

Highlighted

Re: How to insert the values in infotable as a whole in to the external database tables ?

var tableLength = infotables.rows.length;
for (var x=0; x < tableLength; x++) {
var row = infotables.rows[x];
//var result = row.id;
try {
var command = "INSERT INTO containerproduct (containerid,productname ) VALUES ('" +
row.id + "', '" + row.productname + "')";

logger.debug("Database_test.Insert_data_to_database(): Query - " + command);
var result = me.run_command({command: command});
} catch(error) {
logger.error("Database_test.Insert_data_to_database(): Error - " + error.message);
}
}

This the code I am using to insert the data in infotable to external database by local(javascript) service but I am unsuccessful in inserting.

I have written one more service with sql command and that service has an input as command with base type as String and code section is filled with <<command>>

 

Where the command in the above code gives input to the sql command service.

 

Regards,

Bhargav Sai Ch

Highlighted

Re: How to insert the values in infotable as a whole in to the external database tables ?

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!