- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
how to move one row from one table to another table?
Hi, Here i ran into a problem. I have two tables. One is main table which have 847 rows record. It recorded every one min. Now i hope i can click JSL once so that every one min there is one row was automaitically moved from main table to Table 2. That means after 60 mins, there are 60 rows in Table2. 120mins later, there are 120rows in Tables2. Until to the end after 847 mins.
Thanks in advanced.
GMan
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to move one row from one table to another table?
Created:
Nov 8, 2017 11:07 AM
| Last Modified: Nov 8, 2017 8:46 AM
(6764 views)
| Posted in reply to message from GoodMan 11-08-2017
Here is a simplified example of how to do your minute by minute updating. If you do a little playing with it, you should get what you need
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Reduce the number of rows to a reasonable number for the test
dt << select rows( {1, 2, 3} );
dt << invert row selection;
dt << delete rows;
// Create the output table
dt2 = New Table( "update",
New Column( "time updated", Format( "d/m/y h:m:s", 17 ) ),
New Column( "Name", character )
);
Wait( 0 );
// Set the initial values
begin = Today();
TheRow = -1; // set to -1 so first row will be immediatly written
// Loop until the minute has changed, then update
While( TheRow + 2 <= N Rows( dt ),
If( Date Difference( begin, Today(), "Minute", "actual" ) > TheRow,
dt2 << Begin Data Update;
dt2 << Add Rows( 1 );
dt2:time updated[N Rows( dt2 )] = Today();
dt2:Name[N Rows( dt2 )] = dt:Name[TheRow + 2];
dt2 << End Data Update;
Wait(55);
TheRow++;
);
// This is optional, but it should reduce the cpu cycle impact if used
Wait(1);
);
Jim
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to move one row from one table to another table?
Created:
Nov 8, 2017 11:07 AM
| Last Modified: Nov 8, 2017 8:46 AM
(6765 views)
| Posted in reply to message from GoodMan 11-08-2017
Here is a simplified example of how to do your minute by minute updating. If you do a little playing with it, you should get what you need
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// Reduce the number of rows to a reasonable number for the test
dt << select rows( {1, 2, 3} );
dt << invert row selection;
dt << delete rows;
// Create the output table
dt2 = New Table( "update",
New Column( "time updated", Format( "d/m/y h:m:s", 17 ) ),
New Column( "Name", character )
);
Wait( 0 );
// Set the initial values
begin = Today();
TheRow = -1; // set to -1 so first row will be immediatly written
// Loop until the minute has changed, then update
While( TheRow + 2 <= N Rows( dt ),
If( Date Difference( begin, Today(), "Minute", "actual" ) > TheRow,
dt2 << Begin Data Update;
dt2 << Add Rows( 1 );
dt2:time updated[N Rows( dt2 )] = Today();
dt2:Name[N Rows( dt2 )] = dt:Name[TheRow + 2];
dt2 << End Data Update;
Wait(55);
TheRow++;
);
// This is optional, but it should reduce the cpu cycle impact if used
Wait(1);
);
Jim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: how to move one row from one table to another table?
Thank you, Jim. With your help, i realized it.