Updated on 2024-08-20 GMT+08:00

DBE_SCHEDULER

Interface Description

The advanced package DBE_SCHEDULER supports more flexible creation of scheduled tasks through scheduling and programing. For details about all the supported APIs, see Table 1.

Table 1 DBE_SCHEDULER

Interface

Description

DBE_SCHEDULER.CREATE_JOB

Creates a scheduled task.

DBE_SCHEDULER.DROP_JOB

Deletes a scheduled task.

DBE_SCHEDULER.DROP_SINGLE_JOB

Deletes a single scheduled task.

DBE_SCHEDULER.SET_ATTRIBUTE

Sets object attributes.

DBE_SCHEDULER.RUN_JOB

Executes a scheduled task.

DBE_SCHEDULER.RUN_BACKEND_JOB

Runs a scheduled task in the backend.

DBE_SCHEDULER.RUN_FOREGROUND_JOB

Runs a scheduled task in the frontend.

DBE_SCHEDULER.STOP_JOB

Stops a scheduled task.

DBE_SCHEDULER.STOP_SINGLE_JOB

Stops a single scheduled task.

DBE_SCHEDULER.GENERATE_JOB_NAME

Generates the name of a scheduled task.

DBE_SCHEDULER.CREATE_PROGRAM

Creates a program.

DBE_SCHEDULER.DEFINE_PROGRAM_ARGUMENT

Defines program parameters.

DBE_SCHEDULER.DROP_PROGRAM

Deletes a program.

DBE_SCHEDULER.DROP_SINGLE_PROGRAM

Deletes a single program.

DBE_SCHEDULER.SET_JOB_ARGUMENT_VALUE

Sets the parameters of a scheduled task.

DBE_SCHEDULER.CREATE_SCHEDULE

Creates a schedule.

DBE_SCHEDULER.DROP_SCHEDULE

Deletes a schedule.

DBE_SCHEDULER.DROP_SINGLE_SCHEDULE

Deletes a single schedule.

DBE_SCHEDULER.CREATE_JOB_CLASS

Creates the class of a scheduled task.

DBE_SCHEDULER.DROP_JOB_CLASS

Deletes the class of a scheduled task.

DBE_SCHEDULER.DROP_SINGLE_JOB_CLASS

Deletes the class of a single scheduled task.

DBE_SCHEDULER.GRANT_USER_AUTHORIZATION

Grants special permissions to a user.

DBE_SCHEDULER.REVOKE_USER_AUTHORIZATION

Revokes special permissions from a user.

DBE_SCHEDULER.CREATE_CREDENTIAL

Creates a certificate.

DBE_SCHEDULER.DROP_CREDENTIAL

Destroys a certificate.

DBE_SCHEDULER.ENABLE

Enables an object.

DBE_SCHEDULER.ENABLE_SINGLE

Enables a single object.

DBE_SCHEDULER.DISABLE

Disables an object.

DBE_SCHEDULER.DISABLE_SINGLE

Disables a single object.

DBE_SCHEDULER.EVAL_CALENDAR_STRING

Analyzes the scheduling task period.

DBE_SCHEDULER.EVALUATE_CALENDAR_STRING

Analyzes the scheduling task period.

  • DBE_SCHEDULER.CREATE_JOB

    Creates a scheduled task.

    The prototypes of the DBE_SCHEDULER.CREATE_JOB function are as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    -- Scheduled tasks of an inline schedule and a program.
    DBE_SCHEDULER.CREATE_JOB(
    job_name TEXT,
    job_type TEXT,
    job_action TEXT,
    number_of_arguments INTEGER             DEFAULT 0,
    start_date TIMESTAMP WITH TIME ZONE     DEFAULT NULL,
    repeat_interval TEXT                    DEFAULT NULL,
    end_date TIMESTAMP WITH TIME ZONE       DEFAULT NULL,
    job_class TEXT            DEFAULT 'DEFAULT_JOB_CLASS',
    enabled BOOLEAN                         DEFAULT FALSE,
    auto_drop BOOLEAN                       DEFAULT TRUE,
    comments TEXT                           DEFAULT NULL,
    credential_name TEXT                    DEFAULT NULL,
    destination_name TEXT                   DEFAULT NULL
    )
    
    -- Reference the created scheduled tasks of the schedule and the program.
    DBE_SCHEDULER.CREATE_JOB(
    job_name TEXT,
    program_name TEXT,
    schedule_name TEXT,
    job_class TEXT            DEFAULT 'DEFAULT_JOB_CLASS',
    enabled BOOLEAN                         DEFAULT FALSE,
    auto_drop BOOLEAN                       DEFAULT TRUE,
    comments TEXT                           DEFAULT NULL,
    job_style TEXT                          DEFAULT 'REGULAR',
    credential_name TEXT                    DEFAULT NULL,
    destination_name TEXT                   DEFAULT NULL
    )
    
    -- Reference the created program and the scheduled task of the inline schedule.
    DBE_SCHEDULER.CREATE_JOB(
    job_name text,
    program_name TEXT,
    start_date TIMESTAMP WITH TIME ZONE     DEFAULT NULL,
    repeat_interval TEXT                    DEFAULT NULL,
    end_date TIMESTAMP WITH TIME ZONE       DEFAULT NULL,
    job_class TEXT            DEFAULT 'DEFAULT_JOB_CLASS',
    enabled BOOLEAN                         DEFAULT FALSE,
    auto_drop BOOLEAN                       DEFAULT TRUE,
    comments TEXT                           DEFAULT NULL,
    job_style TEXT                          DEFAULT 'REGULAR',
    credential_name TEXT                    DEFAULT NULL,
    destination_name TEXT                   DEFAULT NULL
    )
    
    -- Reference the created schedule and the scheduled task of the inline program.
    DBE_SCHEDULER.CREATE_JOB(
    job_name TEXT,
    schedule_name TEXT,
    job_type TEXT,
    job_action TEXT,
    number_of_arguments INTEGER             DEFAULT 0,
    job_class TEXT             DEFAULT 'DEFAULT_JOB_CLASS',
    enabled BOOLEAN                         DEFAULT FALSE,
    auto_drop BOOLEAN                       DEFAULT TRUE,
    comments TEXT                           DEFAULT NULL,
    credential_name TEXT                    DEFAULT NULL,
    destination_name TEXT                   DEFAULT NULL
    )
    

    The scheduled task created through DBE_SCHEDULER does not conflict with the scheduled task in DBE_TASK.

    The scheduled task created by DBE_SCHEDULER generates the corresponding job_id. However, the job_id is meaningless.

    For the create API, the validity of input parameter types is not verified. Successful creation does not mean successful execution. You can query the execution status of the current task in the pg_job system catalog.

    Table 2 DBE_SCHEDULER.CREATE_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name of a scheduled task.

    job_type

    text

    IN

    No

    Inline program type of a scheduled task. The options are as follows:
    • 'PLSQL_BLOCK': fast anonymous stored procedure.
    • 'STORED_PROCEDURE': stored procedure that is saved.
    • 'EXTERNAL_SCRIPT': external script.

    job_action

    text

    IN

    No

    Content executed by an inline program of a scheduled task.

    number_of_arguments

    integer

    IN

    No

    Number of inline program parameters of a scheduled task.

    program_name

    text

    IN

    No

    Name of the program referenced by a scheduled task.

    start_date

    timestamp with time zone

    IN

    Yes

    Inline scheduling start time of a scheduled task.

    repeat_interval

    text

    IN

    Yes

    Inline scheduling period of a scheduled task. The options are as follows:

    • 'interval N second/minute/hour/day/week/month/year'
    • 'FREQ=secondly/miuntely/hourly/daily/weekly/monthy/yearly; INTERVAL=N'
    • trunc(sysdate+N) + M/24 (indicating that schedule will be started in M hours after N days)

    end_date

    timestamp with time zone

    IN

    Yes

    Inline scheduling expiration time of a scheduled task.

    schedule_name

    text

    IN

    No

    Name of the schedule referenced by a scheduled task.

    job_class

    text

    IN

    No

    Class name of a scheduled task.

    enabled

    boolean

    IN

    No

    Status of a scheduled task.

    auto_drop

    boolean

    IN

    No

    Automatic deletion of a scheduled task.

    comments

    text

    IN

    Yes

    Comments.

    job_style

    text

    IN

    No

    Behavior pattern of a scheduled task. Only 'REGULAR' is supported.

    credential_name

    text

    IN

    Yes

    Certificate name of a scheduled task.

    destination_name

    text

    IN

    Yes

    Target name of a scheduled task.

    Example:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 3, false, 'test');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule1', NULL, 'sysdate', NULL, 'test');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_job(job_name=>'job1', program_name=>'program1', schedule_name=>'schedule1');
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule1');
     drop_schedule 
    ---------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
    

    To create a scheduled task of the EXTERNAL_SCRIPT type, the administrator must assign related permissions and certificates and the user who starts the database must have the read permission on the external script.

  • DBE_SCHEDULER.DROP_JOB

    Deletes a scheduled task.

    The prototype of the DBE_SCHEDULER.DROP_JOB function is as follows:

    1
    2
    3
    4
    5
    6
    DBE_SCHEDULER.drop_job(
    job_name text,
    force boolean                           default false,
    defer boolean                           default false,
    commit_semantics text      default 'STOP_ON_FIRST_ERROR'
    )
    

    DBE_SCHEDULER.DROP_JOB can specify one or more tasks, or specify a task class to delete a scheduled task.

    Table 3 DBE_SCHEDULER.DROP_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name or class of a scheduled task. You can specify one or more scheduled tasks. If you specify multiple scheduled tasks, separate them with commas (,).

    force

    boolean

    IN

    No

    Specifies whether to delete a scheduled task.
    • true: The current scheduled task is stopped and then deleted.
    • false: The scheduled task fails to be deleted if it is running.

    defer

    boolean

    IN

    No

    Specifies whether to delete a scheduled task.
    • true: A scheduled task can be deleted after it is complete.
    • false: The scheduled task cannot be executed and is deleted.

    commit_semantics

    text

    IN

    No

    Commit rules:
    • 'STOP_ON_FIRST_ERROR': The deletion operation performed before the first error is reported is committed.
    • 'TRANSACTIONAL': Transaction-level commit. The deletion operation performed before an error is reported will be rolled back.
    • 'ABSORB_ERRORS': The system attempts to bypass an error and commit the deletion operation that is performed successfully.
    Example:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 3, false, 'test');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule1', NULL, 'sysdate', NULL, 'test');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_job(job_name=>'job1', program_name=>'program1', schedule_name=>'schedule1');
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule1');
     drop_schedule 
    ---------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
    

    The TRANSACTIONAL option in commit_semantic takes effect only when force is set to false.

  • DBE_SCHEDULER.DROP_SINGLE_JOB

    Deletes a scheduled task.

    The prototype of the DBE_SCHEDULER.DROP_SINGLE_JOB function is as follows:

    1
    2
    3
    4
    5
    DBE_SCHEDULER.drop_single_job(
    job_name text,
    force boolean                           default false,
    defer boolean                           default false
    )
    
    Table 4 DBE_SCHEDULER.DROP_SINGLE_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Specifies the name of a scheduled task or scheduled task class.

    force

    boolean

    IN

    No

    Specifies whether to delete a scheduled task.
    • true: The current scheduled task is stopped and then deleted.
    • false: The scheduled task fails to be deleted if it is running.

    defer

    boolean

    IN

    No

    Specifies whether to delete a scheduled task.
    • true: A scheduled task can be deleted after it is complete.
    • false: The scheduled task cannot be executed and is deleted.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 0, false, 'test');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_job('job1', 'program1', '2021-07-20', 'interval ''3 minute''', '2121-07-20', 'DEFAULT_JOB_CLASS', false, false,'test', 'style', NULL, NULL);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_single_job('job1', false, false);
     drop_single_job 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
    
  • DBE_SCHEDULER.SET_ATTRIBUTE

    Modifies the attributes of a scheduled task.

    The prototypes of the DBE_SCHEDULER.SET_ATTRIBUTE function are as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    DBE_SCHEDULER.set_attribute(
    name                    text,
    attribute               text,
    value                   boolean
    )
    
    DBE_SCHEDULER.set_attribute(
    name                    text,
    attribute               text,
    value                   text
    )
    
    DBE_SCHEDULER.set_attribute(
    name                    text,
    attribute               text,
    value                   timestamp
    )
    
    DBE_SCHEDULER.set_attribute(
    name                    text,
    attribute               text,
    value                   timestamp with time zone
    )
    
    DBE_SCHEDULER.set_attribute(
    name text,
    attribute text,
    value text,
    value2 text                             default NULL
    )
    

    name specifies any object in DBE_SCHEDULER.

    Table 5 DBE_SCHEDULER.SET_ATTRIBUTE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    name

    text

    IN

    No

    Object name.

    attribute

    text

    IN

    No

    Attribute name.

    value

    boolean/date/timestamp/timestamp with time zone/text

    IN

    No

    Attribute value. The options are as follows:

    • Scheduled-task-related: job_type, job_action, number_of_arguments, start_date, repeat_interval, end_date, ob_class, enabled, auto_drop, comments, credential_name, destination_name, program_name, schedule_name, and job_style.
    • Program-related: program_action, program_type, number_of_arguments, and comments.
    • Scheduling-related: start_date, repeat_interval, end_date, and comments.

    value2

    text

    IN

    Yes

    Additional attribute value. Reserved parameter bit. Currently, the target attribute with extra attribute values is not supported.

    Example:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 3, false, 'test');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.set_attribute('program1', 'number_of_arguments', 0);
     set_attribute 
    ---------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.set_attribute('program1', 'program_type', 'STORED_PROCEDURE');
     set_attribute 
    ---------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
    

    Do not use DBE_SCHEDULER.SET_ATTRIBUTE to leave the parameters empty.

    The object name cannot be changed using DBE_SCHEDULER.SET_ATTRIBUTE.

  • DBE_SCHEDULER.RUN_JOB

    Executes a scheduled task.

    The prototype of the DBE_SCHEDULER.RUN_JOB function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.run_job(
    job_name text,
    use_current_session boolean             default true
    )
    

    DBE_SCHEDULER.RUN_JOB is used to run scheduled tasks immediately. It is independent of the scheduling of scheduled tasks and can even run at the same time.

    Table 6 DBE_SCHEDULER.RUN_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name of a scheduled task. You can specify one or more scheduled tasks. If you specify multiple scheduled tasks, separate them with commas (,).

    use_current_session

    boolean

    IN

    No

    Specifies whether to run a scheduled task.
    • true: Use the current session to check whether the scheduled task can run properly.
    • false: Start the scheduled task in the background. The execution result is recorded in logs.
    Example:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    gaussdb=# SELECT dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.run_job('job1', false);
     run_job 
    ---------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    

    use_current_session cannot be used to record execution results.

  • DBE_SCHEDULER.RUN_BACKEND_JOB

    Runs a scheduled task in the backend.

    The prototype of the DBE_SCHEDULER.RUN_BACKEND_JOB function is as follows:

    1
    2
    3
    DBE_SCHEDULER.run_backend_job(
    job_name text
    )
    
    Table 7 DBE_SCHEDULER.RUN_BACKEND_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name of a scheduled task.

    Example:

    gaussdb=# SELECT dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.run_backend_job('job1');
     run_backend_job 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
  • DBE_SCHEDULER.RUN_FOREGROUND_JOB

    Executes a scheduled task in the current session.

    Only external tasks can be executed.

    Return value: text

    The prototype of the DBE_SCHEDULER.RUN_FOREGROUND_JOB function is as follows:

    1
    2
    3
    DBE_SCHEDULER.run_foreground_job(
    job_name text
    )return text
    
    Table 8 DBE_SCHEDULER.RUN_FOREGROUND_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name of a scheduled task.

    Example:

    gaussdb=# create user test1 identified by '*********';
    NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
    CREATE ROLE
    gaussdb=# select DBE_SCHEDULER.create_credential('cre_1', 'test1', '*********');
     create_credential 
    -------------------
    
    (1 row)
    
    gaussdb=# select DBE_SCHEDULER.create_job(job_name=>'job1', job_type=>'EXTERNAL_SCRIPT', job_action=>'/usr/bin/pwd', enabled=>true, auto_drop=>false, credential_name => 'cre_1');
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.run_foreground_job('job1');
      run_foreground_job
    ---------------------------------
     Host key verification failed.\r+
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_credential('cre_1', false);
     drop_credential 
    -----------------
    
    (1 row)
    
    gaussdb=# drop user test1;
    DROP ROLE
  • DBE_SCHEDULER.STOP_JOB

    Stops a scheduled task.

    The prototype of the DBE_SCHEDULER.STOP_JOB function is as follows:

    1
    2
    3
    4
    5
    DBE_SCHEDULER.stop_job(
    job_name text,
    force boolean                           default false,
    commit_semantics text                   default 'STOP_ON_FIRST_ERROR'
    )
    
    Table 9 DBE_SCHEDULER.STOP_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name or class of a scheduled task. You can specify one or more scheduled tasks. If you specify multiple scheduled tasks, separate them with commas (,).

    force

    boolean

    IN

    No

    Specifies whether to delete a scheduled task.
    • true: The scheduler sends a termination signal to end the task thread immediately.
    • false: The scheduler attempts to use the interrupt signal to terminate the scheduled task thread.

    commit_semantics

    text

    IN

    No

    Commit rules:
    • 'STOP_ON_FIRST_ERROR': The interrupt operation performed before the first error is reported is committed.
    • 'ABSORB_ERRORS': The system attempts to bypass an error and commit the interrupt operation that is performed successfully.

    Example:

    gaussdb=# SELECT dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.stop_job('job1', true, 'STOP_ON_FIRST_ERROR');
     stop_job 
    ----------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
  • DBE_SCHEDULER.STOP_SINGLE_JOB

    Stops a single scheduled task.

    The prototype of the DBE_SCHEDULER.STOP_SINGLE_JOB function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.stop_single_job(
    job_name text,
    force boolean                           default false
    )
    
    Table 10 DBE_SCHEDULER.STOP_SINGLE_JOB interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Specifies the name of a scheduled task or scheduled task class.

    force

    boolean

    IN

    No

    Specifies whether to delete a scheduled task.
    • true: The scheduler sends a termination signal to end the task thread immediately.
    • false: The scheduler attempts to use the interrupt signal to terminate the scheduled task thread.

    Example:

    gaussdb=# SELECT dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.stop_single_job('job1', true);
     stop_single_job 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    
  • DBE_SCHEDULER.GENERATE_JOB_NAME

    Generates the name of a scheduled task.

    The prototype of the DBE_SCHEDULER.GENERATE_JOB_NAME function is as follows:

    1
    2
    3
    DBE_SCHEDULER.generate_job_name(
    prefix text                             default 'JOB$_'
    )return text
    
    Table 11 DBE_SCHEDULER.GENERATE_JOB_NAME interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    prefix

    text

    IN

    No

    Prefix of the generated name. The default value is 'JOB$_'. Scheduled tasks that are repeatedly executed are named as follows:

    job$_1, job$_2, job$_3 ...

    Example:

    gaussdb=# CALL DBE_SCHEDULER.generate_job_name();
     generate_job_name 
    -------------------
     JOB$_1
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.generate_job_name();
     generate_job_name 
    -------------------
     JOB$_2
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.generate_job_name('job');
     generate_job_name 
    -------------------
     job3
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.generate_job_name('job');
     generate_job_name 
    -------------------
     job4
    (1 row)

    When DBE_SCHEDULER.GENERATE_JOB_NAME is executed for the first time, a temporary sequence is created in public to store the sequence number of the current name. A common user does not have the create permission in public. Therefore, if a common user calls the function for the first time in the current database, the function fails to be called. In this case, you need to grant the create permission in public to the common user or call the API as a user with the create permission to create a temporary sequence.

  • DBE_SCHEDULER.CREATE_PROGRAM

    Creates a program.

    The prototype of the DBE_SCHEDULER.CREATE_PROGRAM function is as follows:

    1
    2
    3
    4
    5
    6
    7
    8
    DBE_SCHEDULER.create_program(
    program_name text,
    program_type text,
    program_action text,
    number_of_arguments integer             default 0,
    enabled boolean                         default false,
    comments text                           default NULL
    )
    
    Table 12 DBE_SCHEDULER.CREATE_PROGRAM interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    program_name

    text

    IN

    No

    Name of a program

    program_type

    text

    IN

    No

    Program type. The options are as follows:
    • 'PLSQL_BLOCK': fast anonymous stored procedure.
    • 'STORED_PROCEDURE': stored procedure that is saved.
    • 'EXTERNAL_SCRIPT': external script.

    program_action

    text

    IN

    No

    Program operation.

    number_of_arguments

    integer

    IN

    No

    Number of parameters used by the program.

    enabled

    boolean

    IN

    No

    Specifies whether the program is enabled.

    comments

    text

    IN

    Yes

    Comments.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 3, false, 'test');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
  • DBE_SCHEDULER.DEFINE_PROGRAM_ARGUMENT

    Defines program parameters.

    An API with the default value default_value will not convert characters to lowercase letters by default. In this version, characters are case sensitive.

    The prototype of the DBE_SCHEDULER.DEFINE_PROGRAM_ARGUMENT function is as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    DBE_SCHEDULER.define_program_argument(
    program_name text,
    argument_position integer,
    argument_name text                      default NULL,
    argument_type text,
    out_argument boolean                    default false
    )
    
    -- With a default value --
    DBE_SCHEDULER.define_program_argument(
    program_name text,
    argument_position integer,
    argument_name text                      default NULL,
    argument_type text,
    default_value text,
    out_argument boolean                    default false
    )
    
    Table 13 DBE_SCHEDULER.DEFINE_PROGRAM_ARGUMENT interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    program_name

    text

    IN

    No

    Name of a program.

    argument_position

    integer

    IN

    No

    Parameter location.

    argument_name

    text

    IN

    No

    Parameter name.

    argument_type

    text

    IN

    No

    Parameter type.

    default_value

    text

    IN

    No

    Default value.

    out_argument

    boolean

    IN

    No

    Reserved parameter.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 2, false, 'test');
    create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.define_program_argument('program1', 1, 'pa1', 'type1', false);
     define_program_argument 
    -------------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.define_program_argument('program1', 1, 'pa1', 'type1', 'value1', false);
     define_program_argument 
    -------------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
  • DBE_SCHEDULER.DROP_PROGRAM

    Deletes a program.

    The prototype of the DBE_SCHEDULER.DROP_PROGRAM function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_program(
    program_name text,
    force boolean                           default false
    )
    
    Table 14 DBE_SCHEDULER.DROP_PROGRAM interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    program_name

    text

    IN

    No

    Name of a program.

    force

    boolean

    IN

    No

    Specifies whether to delete a program.
    • true: Before a program is deleted, all jobs that use the program are disabled.
    • false: The program cannot be referenced by any job. Otherwise, an error is sent.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 2, false, 'test');
    create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
  • DBE_SCHEDULER.DROP_SINGLE_PROGRAM

    Deletes a single program.

    The prototype of the DBE_SCHEDULER.DROP_SINGLE_PROGRAM function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_single_program(
    program_name text,
    force boolean                           default false
    )
    
    Table 15 DBE_SCHEDULER.DROP_SINGLE_PROGRAM interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    program_name

    text

    IN

    No

    Name of a program.

    force

    boolean

    IN

    No

    Specifies whether to delete a program.
    • true: Before a program is deleted, all jobs that use the program are disabled.
    • false: The program cannot be referenced by any job. Otherwise, an error is sent.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'STORED_PROCEDURE', 'select pg_sleep(1);', 2, false, 'test');
    create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_single_program('program1', false);
     drop_single_program 
    ---------------------
    
    (1 row)
  • DBE_SCHEDULER.SET_JOB_ARGUMENT_VALUE

    Sets the parameters of a scheduled task. The argument_value can be left empty.

    The prototype of the DBE_SCHEDULER.SET_JOB_ARGUMENT_VALUE function is as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    DBE_SCHEDULER.set_job_argument_value(
    job_name text,
    argument_position integer,
    argument_value text
    )
    
    DBE_SCHEDULER.set_job_argument_value(
    job_name text,
    argument_name text,
    argument_value text
    )
    
    Table 16 DBE_SCHEDULER.SET_JOB_ARGUMENT_VALUE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_name

    text

    IN

    No

    Name of a scheduled task.

    argument_position

    integer

    IN

    No

    Parameter location.

    argument_name

    text

    IN

    Yes

    Parameter name.

    argument_value

    text

    IN

    Yes

    Parameter value.

    Example:

    gaussdb=# CALL dbe_scheduler.create_job('job1','EXTERNAL_SCRIPT','begin insert into test1 values(12); end;',2,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.set_job_argument_value('job1', 1, 'value1');
     set_job_argument_value 
    ------------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
  • DBE_SCHEDULER.CREATE_SCHEDULE

    Creates a schedule.

    The prototype of the DBE_SCHEDULER.CREATE_SCHEDULE function is as follows:

    1
    2
    3
    4
    5
    6
    7
    DBE_SCHEDULER.create_schedule(
    schedule_name text,
    start_date timestamp with time zone     default NULL,
    repeat_interval text,
    end_date timestamp with time zone       default NULL,
    comments text                           default NULL
    )
    
    Table 17 DBE_SCHEDULER.CREATE_SCHEDULE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    schedule_name

    text

    IN

    No

    Name of a schedule.

    start_date

    timestamp with time zone

    IN

    Yes

    Start time of a schedule.

    repeat_interval

    text

    IN

    No

    Repetition frequency of a schedule.

    end_date

    timestamp with time zone

    IN

    Yes

    End time of a schedule.

    comments

    text

    IN

    Yes

    Comments.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule1', sysdate, 'sysdate + 3 / (24 * 60 * 60)', null, 'test1');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule2', sysdate, 'FREQ=DAILY; BYHOUR=6;', null, 'test1');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule3', sysdate, 'FREQ=DAILY; BYHOUR=6;');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule1');
     drop_single_schedule 
    ----------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule2', false);
     drop_single_schedule 
    ----------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule3', true);
     drop_single_schedule 
    ----------------------
    
    (1 row)
  • DBE_SCHEDULER.DROP_SCHEDULE

    Deletes a schedule.

    The prototype of the DBE_SCHEDULER.DROP_SCHEDULE function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_schedule(
    schedule_name text,
    force boolean                           default false
    )
    
    Table 18 DBE_SCHEDULER.DROP_SCHEDULE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    schedule_name

    text

    IN

    No

    Name of a schedule.

    force

    boolean

    IN

    No

    Specifies whether to delete a schedule.
    • true: Any jobs or windows that use this schedule are disabled before the schedule is deleted.
    • false: The schedule cannot be referenced by any job or window. Otherwise, an error occurs.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule1', sysdate, 'sysdate + 3 / (24 * 60 * 60)', null, 'test1');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule2', sysdate, 'FREQ=DAILY; BYHOUR=6;', null, 'test1');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule3', sysdate, 'FREQ=DAILY; BYHOUR=6;');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule1');
     drop_single_schedule 
    ----------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule2', false);
     drop_single_schedule 
    ----------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_schedule('schedule3', true);
     drop_single_schedule 
    ----------------------
    
    (1 row)
  • DBE_SCHEDULER.DROP_SINGLE_SCHEDULE

    Deletes a single schedule.

    The prototype of the DBE_SCHEDULER.DROP_SINGLE_SCHEDULE function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_single_schedule(
    schedule_name text,
    force boolean                           default false
    )
    
    Table 19 DBE_SCHEDULER.DROP_SINGLE_SCHEDULE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    schedule_name

    text

    IN

    No

    Name of a schedule.

    force

    boolean

    IN

    No

    Specifies whether to delete a schedule.
    • true: Any jobs or windows that use this schedule are disabled before the schedule is deleted.
    • false: The schedule cannot be referenced by any job or window. Otherwise, an error occurs.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule1', sysdate, 'sysdate + 3 / (24 * 60 * 60)', null, 'test1');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule2', sysdate, 'FREQ=DAILY; BYHOUR=6;', null, 'test1');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_schedule('schedule3', sysdate, 'FREQ=DAILY; BYHOUR=6;');
     create_schedule 
    -----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_single_schedule('schedule1');
     drop_single_schedule 
    ----------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_single_schedule('schedule2', false);
     drop_single_schedule 
    ----------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_single_schedule('schedule3', true);
     drop_single_schedule 
    ----------------------
    
    (1 row)
  • DBE_SCHEDULER.CREATE_JOB_CLASS

    Creates the class of a scheduled task.

    The prototype of the DBE_SCHEDULER.CREATE_JOB_CLASS function is as follows:

    1
    2
    3
    4
    5
    6
    7
    8
    DBE_SCHEDULER.create_job_class(
    job_class_name text,
    resource_consumer_group text            default NULL,
    service text                            default NULL,
    logging_level integer                   default 0,
    log_history integer                     default NULL,
    comments text                           default NULL
    )
    
    Table 20 DBE_SCHEDULER.CREATE_JOB_CLASS interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_class_name

    text

    IN

    No

    Name of a scheduled task class.

    resource_consumer_group

    text

    IN

    Yes

    Inline resource consumer group of a scheduled task class.

    service

    text

    IN

    Yes

    Inline database service of a scheduled task class.

    logging_level

    integer

    IN

    No

    Number of scheduled task records.

    log_history

    integer

    IN

    Yes

    Number of days for storing scheduled task records.

    comments

    text

    IN

    Yes

    Comments.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_job_class(job_class_name => 'jc1', resource_consumer_group => '123');
     create_job_class 
    ------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job_class('jc1', false);
     drop_job_class 
    ----------------
    
    (1 row)
  • DBE_SCHEDULER.DROP_JOB_CLASS

    Deletes the class of a scheduled task.

    The prototype of the DBE_SCHEDULER.DROP_JOB_CLASS function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_job_class(
    job_class_name text,
    force boolean                           default false
    )
    
    Table 21 DBE_SCHEDULER.DROP_JOB_CLASS interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_class_name

    text

    IN

    No

    Name of a scheduled task class.

    force

    boolean

    IN

    No

    Specifies whether to delete a scheduled task class.
    • true: Jobs of this class will be disabled, and another class will be set as the default class. Only when such setting is successful, this class will be deleted.
    • false: The class to be deleted cannot be referenced by any job. Otherwise, an error occurs.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_job_class(job_class_name => 'jc1', resource_consumer_group => '123');
     create_job_class 
    ------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job_class('jc1', false);
     drop_job_class 
    ----------------
    
    (1 row)
  • DBE_SCHEDULER.DROP_SINGLE_JOB_CLASS

    Deletes the class of a single scheduled task.

    The prototype of the DBE_SCHEDULER.DROP_SINGLE_JOB_CLASS function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_single_job_class(
    job_class_name text,
    force boolean                           default false
    )
    
    Table 22 DBE_SCHEDULER.DROP_SINGLE_JOB_CLASS interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    job_class_name

    text

    IN

    No

    Name of a scheduled task class.

    force

    boolean

    IN

    No

    Specifies whether to delete a scheduled task class.
    • true: Jobs of this class will be disabled, and another class will be set as the default class. Only when such setting is successful, this class will be deleted.
    • false: The class to be deleted cannot be referenced by any job. Otherwise, an error occurs.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_job_class(job_class_name => 'jc1', resource_consumer_group => '123');
     create_job_class 
    ------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_single_job_class('jc1', false);
     drop_job_class 
    ----------------
    
    (1 row)
  • DBE_SCHEDULER.GRANT_USER_AUTHORIZATION

    Grants the scheduled task permissions to the database user. The user who calls this function must have the SYSADMIN permission.

    The prototype of the DBE_SCHEDULER.GRANT_USER_AUTHORIZATION function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.grant_user_authorization(
    username                text,
    privilege               text
    )
    
    Table 23 DBE_SCHEDULER.GRANT_USER_AUTHORIZATION interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    username

    text

    IN

    No

    Database username.

    privilege

    text

    IN

    No

    Scheduled task permission.

    Example:

    gaussdb=# create user user1 password '1*s*****';
    NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
    CREATE ROLE
    gaussdb=# CALL DBE_SCHEDULER.grant_user_authorization('user1', 'create job');
     grant_user_authorization 
    --------------------------
    
    (1 row)
    gaussdb=# drop user user1;
    DROP ROLE
  • DBE_SCHEDULER.REVOKE_USER_AUTHORIZATION

    Revokes the scheduled task permissions from the database user. The user who calls this function must have the SYSADMIN permission.

    The prototype of the DBE_SCHEDULER.REVOKE_USER_AUTHORIZATION function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.revoke_user_authorization(
    username                text,
    privilege               text
    )
    
    Table 24 DBE_SCHEDULER.REVOKE_USER_AUTHORIZATION interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    username

    text

    IN

    No

    Database username.

    privilege

    text

    IN

    No

    Scheduled task permission.

    Example:

    gaussdb=# create user user1 password '1*s*****';
    NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
    CREATE ROLE
    gaussdb=# CALL DBE_SCHEDULER.grant_user_authorization('user1', 'create job');
     grant_user_authorization 
    --------------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.revoke_user_authorization('user1', 'create job');
     revoke_user_authorization 
    ---------------------------
    
    (1 row)
    gaussdb=# drop user user1;
    DROP ROLE
  • DBE_SCHEDULER.CREATE_CREDENTIAL

    Creates an authorization certificate. The user who calls this function must have the SYSADMIN permission.

    The prototype of the DBE_SCHEDULER.CREATE_CREDENTIAL function is as follows:

    1
    2
    3
    4
    5
    6
    7
    8
    DBE_SCHEDULER.create_credential(
    credential_name         text,
    username                text,
    password                text            default NULL,
    database_role           text            default NULL,
    windows_domain          text            default NULL,
    comments                text            default NULL
    )
    
    Table 25 DBE_SCHEDULER.CREATE_CREDENTIAL interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    credential_name

    text

    IN

    No

    Name of the authorization certificate.

    username

    text

    IN

    No

    Database username.

    password

    text

    IN

    Yes

    User password.

    database_role

    text

    IN

    Yes

    Database system permission.

    windows_domain

    text

    IN

    Yes

    Domain to which a Windows user belongs.

    comments

    text

    IN

    Yes

    Comments.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_credential('cre_1', 'user1', '');
     create_credential 
    -------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_credential('cre_1', false);
     drop_credential 
    -----------------
    
    (1 row)

    The password parameter of DBE_SCHEDULER.CREATE_CREDENTIAL must be set to NULL or '******'. This parameter is used only for compatibility and does not indicate any actual meaning. Do not use the OS username corresponding to the installation user to create a certificate.

  • DBE_SCHEDULER.DROP_CREDENTIAL

    Destroys an authorization certificate. The user who calls this function must have the SYSADMIN permission.

    The prototype of the DBE_SCHEDULER.DROP_CREDENTIAL function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.drop_credential(
    credential_name  text,
    force            boolean default false      
    )
    
    Table 26 DBE_SCHEDULER.DROP_CREDENTIAL interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    credential_name

    text

    IN

    No

    Name of the authorization certificate.

    force

    boolean

    IN

    No

    Specifies whether to delete the authorization certificate.
    • true: The certificate will be deleted no matter whether it is referenced by any job.
    • false: No job can reference the certificate. Otherwise, an error occurs.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.create_credential('cre_1', 'user1', '');
     create_credential 
    -------------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_credential('cre_1', false);
     drop_credential 
    -----------------
    
    (1 row)
  • DBE_SCHEDULER.ENABLE

    Enables an object.

    The prototype of the DBE_SCHEDULER.ENABLE function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.enable(
    name text,
    commit_semantics text                   default 'STOP_ON_FIRST_ERROR'
    )
    
    Table 27 DBE_SCHEDULER.ENABLE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    name

    text

    IN

    No

    Object name. You can specify one or more objects. If you specify multiple objects, separate them with commas (,).

    commit_semantics

    text

    IN

    No

    Commit rules. The following types are supported:
    • 'STOP_ON_FIRST_ERROR': The enabling operation performed before the first error is reported is committed.
    • 'TRANSACTIONAL': Transaction-level commit. The enabling operation performed before an error is reported will be rolled back.
    • 'ABSORB_ERRORS': The system attempts to bypass an error and commit the enabling operation that is performed successfully.

    Example:

    gaussdb=# CALL dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
    lse, 'test');
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'stored_procedure', 'insert into tb_job_test(key) values(null);', 0, false, '');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.enable('job1');
     enable 
    --------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.enable('program1', 'STOP_ON_FIRST_ERROR');
     enable 
    --------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
  • DBE_SCHEDULER.ENABLE_SINGLE

    Enables a single object.

    The prototype of the DBE_SCHEDULER.ENABLE_SINGLE function is as follows:

    1
    2
    3
    DBE_SCHEDULER.enable_single(
    name text
    )
    
    Table 28 DBE_SCHEDULER.ENABLE_SINGLE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    name

    text

    IN

    No

    Object name.

    Example:

    gaussdb=# CALL dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
    lse, 'test');
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.enable_single('job1');
     enable_single 
    ---------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
  • DBE_SCHEDULER.DISABLE

    Disables multiple objects. The value of name is a character string separated by commas (,). Each character string separated by commas (,) is an object. Operations are synchronized only when operation synchronization is enabled.

    The prototype of the DBE_SCHEDULER.DISABLE function is as follows:

    1
    2
    3
    4
    5
    DBE_SCHEDULER.disable(
    name text,
    force boolean                           default false,
    commit_semantics text                   default 'STOP_ON_FIRST_ERROR'
    )
    
    Table 29 DBE_SCHEDULER.DISABLE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    name

    text

    IN

    No

    Object name.

    force

    boolean

    IN

    No

    Specifies whether to disable an object.
    • true: The object is disabled regardless of whether other objects depend on it.
    • false: No object can depend on the object. Otherwise, an error occurs.

    commit_semantics

    text

    IN

    No

    Commit rules. The following types are supported:
    • 'STOP_ON_FIRST_ERROR': The disabling operation performed before the first error is reported is committed.
    • 'TRANSACTIONAL': Transaction-level commit. The disabling operation performed before an error is reported will be rolled back.
    • 'ABSORB_ERRORS': The system attempts to bypass an error and commit the disabling operation that is performed successfully.

    Example:

    gaussdb=# CALL dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.create_program('program1', 'stored_procedure', 'insert into tb_job_test(key) values(null);', 0, false, '');
     create_program 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.disable('job1');
     disable 
    ---------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.disable('program1', false, 'STOP_ON_FIRST_ERROR');
     disable 
    ---------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_program('program1', false);
     drop_program 
    --------------
    
    (1 row)
  • DBE_SCHEDULER.DISABLE_SINGLE

    Disables a single object.

    The prototype of the DBE_SCHEDULER.DISABLE_SINGLE function is as follows:

    1
    2
    3
    4
    DBE_SCHEDULER.disable_single(
    name text,
    force boolean                           default false
    )
    
    Table 30 DBE_SCHEDULER.DISABLE_SINGLE interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    name

    text

    IN

    No

    Object name.

    force

    boolean

    IN

    No

    Specifies whether to disable an object.
    • true: The object is disabled regardless of whether other objects depend on it.
    • false: No object can depend on the object. Otherwise, an error occurs.

    Example:

    gaussdb=# CALL dbe_scheduler.create_job('job1','PLSQL_BLOCK','begin insert into test1 values(12); end;',0,null,null,null,'DEFAULT_JOB_CLASS',false,false,null,null,null);
     create_job 
    ------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.disable_single('job1', false);
     disable_single 
    ----------------
    
    (1 row)
    
    gaussdb=# CALL DBE_SCHEDULER.drop_job('job1', true, false, 'STOP_ON_FIRST_ERROR');
     drop_job 
    ----------
    
    (1 row)
  • DBE_SCHEDULER.EVAL_CALENDAR_STRING

    Analyzes the scheduling task period.

    Return type: timestamp with time zone

    The prototype of the DBE_SCHEDULER.EVAL_CALENDAR_STRING function is as follows:

    1
    2
    3
    4
    5
    DBE_SCHEDULER.evaluate_calendar_string(
    IN calendar_string text,
    IN start_date timestamp with time zone,
    IN return_date_after timestamp with time zone
    )return timestamp with time zone
    
    Table 31 DBE_SCHEDULER.EVAL_CALENDAR_STRING interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    calendar_string

    text

    IN

    No

    Date string of a scheduled task.

    start_date

    timestamp with time zone

    IN

    No

    Start time of a scheduled task.

    return_date_after

    timestamp with time zone

    IN

    No

    Date when a scheduled task is returned.

    Example:

    gaussdb=# CALL DBE_SCHEDULER.eval_calendar_string('FREQ=DAILY; BYHOUR=6;', sysdate, sysdate);
      eval_calendar_string  
    ------------------------
     2023-09-16 06:05:55+08
    (1 row)
  • DBE_SCHEDULER.EVALUATE_CALENDAR_STRING

    Analyzes the scheduling task period.

    Return type: timestamp with time zone

    The prototype of the DBE_SCHEDULER.EVALUATE_CALENDAR_STRING function is as follows:

    1
    2
    3
    4
    5
    6
    DBE_SCHEDULER.evaluate_calendar_string(
    IN calendar_string text,
    IN start_date timestamp with time zone,
    IN return_date_after timestamp with time zone,
    OUT next_run_date timestamp with time zone
    )return timestamp with time zone
    
    Table 32 DBE_SCHEDULER.EVALUATE_CALENDAR_STRING interface parameters

    Parameter

    Type

    Input/Output Parameter

    Can Be Empty

    Description

    calendar_string

    text

    IN

    No

    Date string of a scheduled task.

    start_date

    timestamp with time zone

    IN

    No

    Start time of a scheduled task.

    return_date_after

    timestamp with time zone

    IN

    No

    Date when a scheduled task is returned.

    next_run_date

    timestamp with time zone

    OUT

    No

    The next date when a scheduled task is returned.

    Example:

    gaussdb=# CREATE OR REPLACE PROCEDURE pr1(calendar_str text) as
     DECLARE
         start_date        timestamp with time zone;
         return_date_after timestamp with time zone;
         next_run_date     timestamp with time zone;
     BEGIN
         start_date := '2003-2-1 10:30:00.111111+8'::timestamp with time zone;
         return_date_after := start_date;
         DBE_SCHEDULER.evaluate_calendar_string(
             calendar_str,
             start_date, return_date_after, next_run_date);
         DBE_OUTPUT.PRINT_LINE('next_run_date: ' || next_run_date);
         return_date_after := next_run_date;
     END;
     /
    CREATE PROCEDURE
    gaussdb=# CALL pr1('FREQ=hourly;INTERVAL=2;BYHOUR=6,10;BYMINUTE=0;BYSECOND=0');
    next_run_date: 2003-02-02 06:00:00+08
     pr1 
    -----
    
    (1 row)