Stored Procedures [dbo].[ujo_send_event]
Properties
PropertyValue
ANSI Nulls OnYes
Quoted Identifier OnYes
Parameters
NameData TypeMax Length (Bytes)
@eoidvarchar(12)12
@joidint4
@job_namevarchar(64)64
@box_namevarchar(64)64
@AUTOSERVvarchar(30)30
@priorityint4
@eventint4
@statusint4
@alarmint4
@event_time_gmtint4
@exit_codeint4
@machinevarchar(80)80
@pidint4
@jc_pidint4
@run_numint4
@ntryint4
@textvarchar(255)255
@que_priorityint4
Permissions
TypeActionOwning Principal
GrantExecuteujoadmin
SQL Script
create proc ujo_send_event
    @eoid       varchar(12),
    @joid       int,
    @job_name   varchar(64),
    @box_name   varchar(64),
    @AUTOSERV   varchar(30),
    @priority   int,
    @event      int,
    @status     int,
    @alarm      int,
    @event_time_gmt int,
    @exit_code  int,
    @machine    varchar(80),
    @pid        int,
    @jc_pid     int,
    @run_num    int,
    @ntry       int,
    @text       varchar(255),
    @que_priority   int    

AS
declare @counter varchar(7)
declare @evt_num int
declare @l_instance varchar(4)
declare @l_event_time_gmt int
declare @l_gmt_offset int
declare @job_type char(1)
declare @count int

declare @charpos int
declare @nod_name varchar(65)
declare @nod_ckpt varchar(16)
declare @nod_boot varchar(16)

/* STAR 11631087 */
if (@event = 101 AND
    (@status = 1 OR @status = 4 OR @status = 5 OR @status = 6 OR @status = 10))
begin
    select @priority = 10
end

begin tran    /* Star 15150121 */

select @l_instance = str_val from ujo_alamode where type = 'AUTOSERV'
update ujo_next_oid set oid = oid + 1 where field = 'evt_num'
select @evt_num = oid - 1 from ujo_next_oid where field = 'evt_num'

commit    /* Star 15150121 */

if ( @l_instance != @AUTOSERV OR (@event = 101 AND (@status = 1 OR @status = 3 OR @status = 4 OR @status = 5 OR @status = 6 OR @status = 10)) )
begin
    select @l_event_time_gmt = datediff( ss,'01/01/1970', getdate() )
    select @l_gmt_offset = int_val from ujo_alamode where type = 'gmt_offset'
    select @l_event_time_gmt =  @l_event_time_gmt + @l_gmt_offset
    if (@event = 101 AND @status = 10)
    begin
        select @l_event_time_gmt = @l_event_time_gmt + 2
    end

end
else
begin
    select @l_event_time_gmt = @event_time_gmt
end

/* Update the asbnode table if necessary */
if (substring(@eoid, 4, 1) = 'y')
begin
    select @charpos = charindex('$$UJM_NODE$$', @text)
    if (@charpos != 0)
    begin
        select @nod_name = substring(@text, @charpos + 12, 65)
        select @nod_name = upper(@nod_name)
        select @nod_ckpt = substring(@text, @charpos + 77, 16)
        select @nod_boot = substring(@text, @charpos + 93, 16)
        
        begin tran    /* Star 15150121 */
        
        if (select TOP 1 1 from ujo_asbnode where nod_name=@nod_name) = 1
        begin
            update ujo_asbnode set nod_ckpt=@nod_ckpt, nod_boot=@nod_boot
                where nod_name=@nod_name
            
        end
        else
        begin            
            insert into ujo_asbnode (nod_name, nod_ckpt, nod_boot)
                values (@nod_name, @nod_ckpt, @nod_boot)
        end
        
        commit    /* Star 15150121 */
    end
end

/* Added for issue number 9344983 - Xia Lin */
if (@event = 12345)
begin
   select @event = 101

   if (@status = 1 OR @status = 3 OR @status = 4 OR @status = 5 OR @status = 6 OR @status = 8)
   begin
      select @l_event_time_gmt = @event_time_gmt
   end
end

/* Ended for issue number 9344983 - Xia Lin */
if exists(select eoid from ujo_event where eoid = @eoid) or exists(select eoid from ujo_proc_event where eoid = @eoid)
begin
    if exists ( select eoid from ujo_event where eoid = @eoid and
        (job_name = @job_name AND event = @event AND status = @status
        AND ntry = @ntry ))
       or exists ( select eoid from ujo_proc_event where eoid = @eoid and
        (job_name = @job_name AND event = @event AND status = @status
        AND ntry = @ntry ))
    /* Issue 10725507/2 -sinpr01 don't compare event_time_gmt */
    begin
        /* Really is the same event */
        print 'This Event was already here'
        return 1
    end

    select @counter = counter from ujo_last_Eoid_counter

    insert ujo_event2
    ( eoid,stamp,joid,job_name,box_name,AUTOSERV,
    priority,event,status,alarm,
    event_time_gmt,exit_code,
    machine,pid, jc_pid, run_num, ntry, text, que_priority,
    evt_num, que_status, que_status_stamp,
    counter
    )
    values  ( @eoid, getdate(),@joid,@job_name,@box_name,@AUTOSERV,
    @priority,@event, @status,
    @alarm, @l_event_time_gmt, @exit_code,
    @machine, @pid, @jc_pid, @run_num, @ntry, @text, @que_priority,
    @evt_num, 0, getdate(),
    @counter )

    print 'Detected duplicate event.'
    return -1       /* -1 => SE_DUP_EVENT */
end
/* get a run_num (Needed for autorep reports sendevents & missing heartbeat) */
    /* IF this causes blocks, we'll think about it
    */


if @run_num = 0 and @joid != 0
begin
    select  @run_num = run_num
    from    ujo_job_status
    where   joid = @joid

    if @run_num is NULL
    begin
        select @run_num = 0
    end
end

/* PUT this INTO the event table */
begin tran    /* Star 15150121 */

insert  ujo_event
    ( eoid,stamp,joid,job_name,box_name,AUTOSERV,
    priority,event,status,alarm,
    event_time_gmt,exit_code,
    machine,pid, jc_pid, run_num, ntry, text, que_priority,
    evt_num, que_status, que_status_stamp )
values  ( @eoid, getdate(),@joid,@job_name,@box_name,@AUTOSERV,
    @priority,@event, @status,
    @alarm, @l_event_time_gmt, @exit_code,
    @machine, @pid, @jc_pid, @run_num, @ntry, @text, @que_priority,
    @evt_num, 0, getdate() )    
  
if @@rowcount = 1
begin
    if ( @event = 106 )  /* ALARM! - stub out alarm table */
    begin
        insert  ujo_alarm
            ( eoid,alarm,alarm_time,job_name,joid,
              state,state_time,evt_num, event_comment,
              len, response )
        values  ( @eoid,@alarm,@l_event_time_gmt,@job_name,@joid,
              43, @l_event_time_gmt, 0, @text, /*43=OPEN*/
              1, ' ' )
    end
    
    commit    /* Star 15150121 */
    return 1
end

commit    /* Star 15150121 */
return 2
GO
GRANT EXECUTE ON  [dbo].[ujo_send_event] TO [ujoadmin]
GO
Uses
Used By