Adding a user-defined action to your database is a 2-step process:
Your function needs to be wrapped in a
CREATE statement. You can also use
CREATE OR REPLACE, although this is not recommended. This statement also
allows you to define the language of your commands in this statement.
User-defined actions can be written in any language you choose. This guide uses
the SQL procedural language PL/pgSQL.
This example defines a simple procedure that raises a notice:
To make the job scheduler run your action, you need to register it. Use the
add_job function. Supply the name of your action, the schedule
you want it to run on, and the content of your config. If your job needs no
parameters, use a NULL config.
add_job call returns a
job_id. It stores the
the TimescaleDB catalog.
The action runs on the schedule you set. It also runs when you manually start it
run_job with the
job_id. When it runs, the
config are passed as arguments to the procedure.
To list all currently registered jobs, query
Found an issue on this page?Report an issue!