Skip to main content
10-Marble
November 16, 2018
Solved

in Thingworx How to archive data table everyday since two years?

  • November 16, 2018
  • 2 replies
  • 2388 views

I have created table1 for daily direction in "Mysql workbench 6.3 CE" with 11 Rows , I want to archive all data table in another table archive every day since 2 years to have all history. How can I write such a table?

This the table script:

CREATE TABLE ``table1(
IDINT(11) NOT NULL,
tskVARCHAR(200) NULL DEFAULT NULL,
labelVARCHAR(45) NULL DEFAULT NULL,
statVARCHAR(10) NULL DEFAULT NULL,
noteVARCHAR(200) NULL DEFAULT NULL,
dateVARCHAR(45) NULL DEFAULT NULL,
recVARCHAR(45) NULL DEFAULT NULL,
 PRIMARY KEY (ID),
 UNIQUE INDEXID_UNIQUE(ID` ASC));
Best answer by Islam_Amer

Hello Everyone,

 

we use coding 

- API to set all table status by default Open 

- set API Loop all Rows if User change status from Open to any other word it will move the row in to another table

 

 

2 replies

5-Regular Member
November 16, 2018

Hello.

 

I gather you are using MySQL for your persistent storage?

 

Have you tried something like this?

 

Disclaimer: this comes from a 3rd-party MySQL support area, and not from PTC. Use at your own risk and on a test system before trying it in production.

 

Suppose you have mydb.mytb and you want to create mydb.mytbcopy

In the mysql client, run the following

USE mydb
CREATE TABLE mytbcopy LIKE mytb;
INSERT INTO mytbcopy SELECT * FROM mytb;

 

Thanks,

 

-- Craig A.

 

 
10-Marble
November 17, 2018

Hello Craig ,

Thanks for Reply

 

I gather you are using MySQL for your persistent storage? Yes , i use MySql Workbench 6.3 CE

 

in attached pic from the DB where i supposed to write this code ?

 

 

 

 

 

5-Regular Member
December 5, 2018

Hello.

 

Based on the picture you attached and your earlier post, it looks like your earlier CREATE statement should be used to create the backup (copy-to) table and then the SELECT statement that's in your screen grab would be included inside the INSERT INTO statement.

 

Thanks,

 

-- Craig A.

Islam_Amer10-MarbleAuthorAnswer
10-Marble
December 22, 2018

Hello Everyone,

 

we use coding 

- API to set all table status by default Open 

- set API Loop all Rows if User change status from Open to any other word it will move the row in to another table