Hello World?

Hello World?

Hello World? Timer Demo

Let’s make the “Hello World” of the timer.

Make a tql script of “Hello World”

Open tql editor, copy the code below and save it as helloworld.tql.

FAKE(arrange(1, 2, 2))
MAPVALUE(0, 'helloworld')
MAPVALUE(1, time('now'))
MAPVALUE(2, random())
INSERT("name", "time", "value", table("example"))

Execute the script and it will insert a single record into the EXAMPLE table. Run SELECT SQL to see if it works correctly.

select * from example where name = 'helloworld';
sys machbase-neo» select * from example where name = 'helloworld';
┌────────┬────────────┬─────────────────────────┬────────────────────┐
│ ROWNUM │ NAME       │ TIME(LOCAL)             │ VALUE              │
├────────┼────────────┼─────────────────────────┼────────────────────┤
│      1 │ helloworld │ 2024-06-19 18:20:07.001 │ 0.6132387755535856 │
└────────┴────────────┴─────────────────────────┴────────────────────┘
a row fetched.

Timer from Web UI

This timer function on the web Since v8.0.20 is equivalent to the procedure described by the following shell commands.

Register a new timer

Query the result of the timer

sys machbase-neo» select * from example where name = 'helloworld';
┌────────┬────────────┬─────────────────────────┬─────────────────────┐
│ ROWNUM │ NAME       │ TIME(LOCAL)             │ VALUE               │
├────────┼────────────┼─────────────────────────┼─────────────────────┤
│      1 │ helloworld │ 2024-06-19 18:20:07.001 │ 0.6132387755535856  │
│      2 │ helloworld │ 2024-06-19 18:20:17.002 │ 0.02379315559764414 │
│      3 │ helloworld │ 2024-06-19 18:20:27.006 │ 0.3031052549664646  │
│      4 │ helloworld │ 2024-06-19 18:20:37.001 │ 0.9319196302114505  │
│      5 │ helloworld │ 2024-06-19 18:20:47.001 │ 0.9544471210377455  │
└────────┴────────────┴─────────────────────────┴─────────────────────┘
5 rows fetched.

Control timers

Timer shell commands

New timer

Open machbase-neo shell and register a new timer to run the script in every 5 seconds.

timer add helloworld "@every 5s" helloworld.tql; 

List timers

Run timer list to verify your registration.

machbase-neo» timer list;
╭────────────┬────────────┬────────────────┬───────────┬───────╮
│ NAME       │ SPEC       │ TQL            │ AUTOSTART │ STATE │
├────────────┼────────────┼────────────────┼───────────┼───────┤
│ HELLOWORLD │ @every 5s  │ helloworld.tql │ false     │ STOP  │
╰────────────┴────────────┴────────────────┴───────────┴───────╯

Since we did not set --autostart option, the state of the task is STOP.

Start timer

Make it start to run.

timer start helloworld;
machbase-neo» timer list;
╭────────────┬────────────┬────────────────┬───────────┬─────────╮
│ NAME       │ SPEC       │ TQL            │ AUTOSTART │ STATE   │
├────────────┼────────────┼────────────────┼───────────┼─────────┤
│ HELLOWORLD │ @every 5s  │ helloworld.tql │ false     │ RUNNING │
╰────────────┴────────────┴────────────────┴───────────┴─────────╯

Stop the timer

Stop the timer by shell command

timer stop helloworld;
Last updated on