Here you are:

do $$
declare
    job_id int;
begin

    /* add a job and get its id: */
    insert into
        pgagent.pga_job (
        jobjclid
        , jobname
        )
    values
        (
        1 /*1=Routine Maintenance*/
        , 'DELETE_NAMES' /* job name */
        )
    returning
        jobid
    into
        job_id;


    /* add a step to the job: */
    insert into
        pgagent.pga_jobstep (jstjobid, jstname, jstkind, jstcode,
jstdbname)
    values
        (
            job_id
            , 'DELETE_NAMES' /* step name */
            , 's'                    /* sql step */
            , 'BEGIN DELETE_NAMES; END;'  /* the sql to run */
            , 'somedatabase'                  /* the name of the database
to run the step against */
        );


    /* add a schedule to the job. This one runs every day at midnight: */
    insert into pgagent.pga_schedule (
jscjobid
, jscname
, jscdesc
, jscminutes
, jschours
, jscweekdays
, jscmonthdays
, jscmonths
, jscenabled
, jscstart
, jscend)
    values(
job_id
, 'schedule name'
, ''
,
'{t,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f}'
, '{t,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f}'
, '{f,f,f,f,f,f,f}'
, '{f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f}'
, '{f,f,f,f,f,f,f,f,f,f,f,f}'
, true
, '2015-04-06 00:00:00'
, NULL
    );


end $$;


On Thu, Apr 2, 2015 at 12:25 PM, Champion Always <c2627...@gmail.com> wrote:

> Hi,
>            job_name => 'DELETE_NAMES'
>      ,job_type => 'PLSQL_BLOCK'
>      ,job_action => 'BEGIN DELETE_NAMES; END;'
>      ,start_date => sysdate
>      ,repeat_interval => 'FREQ=DAILY'
>      ,enabled => TRUE);
> it is oracle ..
>
> .And i installed pgAgent On postgres ..
> how  above oracle code can convert to postgres and place it in pgagent for
> daily schedule....
> any help..?
>

Reply via email to