question

Farah A avatar image
0 Likes"
Farah A asked Farah A answered

Export new added row from global table to SQL database

Greeting everyone,

I have built a model in which I add rows and columns in a global table using process flow.

I want to export the added row simultaneously in my sql table, this means each time a row is added in my global table, it should be added at the same time in my database.

My question is how can i automatically export the data without having to do it manually from DBconnector ? what trigger is needed ?

i have basic knowledge in sql, which query can help me do that ?

Thank you for your help folks

sql queriesexport datadatabase connector
· 8
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

tannerp avatar image tannerp commented ·

Hi @Farah A,

To add a new column, I think you could execute SQL code like what's below:

ALTER TABLE MyTable
ADD NewColumn varchar(255);

You would just execute it at the same time the new column is created. I'm not entirely sure the best way to do this, though. It's just an idea.

As for automatically exporting all this data, you might look at this question or at the User Manual section entitled, "Excel Interface".

0 Likes 0 ·
Farah A avatar image Farah A tannerp commented ·

thanks for your answer. but i want it to add the data that are in my global table. i can do this by exporting it in my DBConnectors but i want it to be added each time there's a new value

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ Farah A commented ·

No trigger is going to fire when you add a row to a global table. If you want to export after adding the row, then you need to adjust your code everywhere you add a row to add the row and then also export.

You could wrap those two operations together into a user command if you wanted.

0 Likes 0 ·
Show more comments
Benjamin W2 avatar image Benjamin W2 commented ·

Hi @Farah A,

Do you still need help with this?

0 Likes 0 ·

1 Answer

Farah A avatar image
0 Likes"
Farah A answered

Thanks @Benjamin W2 for your consideration,this code worked well for me to write in MysqlDatabase :

Database.Connection con = Database.Connection("DBConnector1");

con.connect();

Database.PreparedStatement statement = con.prepareStatement("INSERT INTO Table1 (id) VALUES (:id )");

statement.bindParam("id", Table("Date DG")[Table("Date DG").numRows][1], Database.DataType.Int);

statement.execute();

con.disconnect();

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.