open-insight/LSL2/STPROC/MODS_UPDATE.txt
Infineon\StieberD 7762b129af pre cutover push
2024-09-04 20:33:41 -07:00

106 lines
3.2 KiB
Plaintext

function mods_update()
$insert logical
$insert rlist_equates
$insert msg_equates
declare function utility, msg, mods_load_control
declare subroutine record_lock, recompile_proc
Stmt = 'SELECT MODS BY PRIORITY BY MOD_DATE BY MOD_TIME' ;* WE HAVE REMOVED ALL DUPLICATES
;* SO NOW ALL WE HAVE TO DO IS APPLY IN THE
;* ORDER THAT THEY WERE PERFORMED
Stat = utility( 'CURSOR', 'H' )
rlist( Stmt, target_activelist$, '', '', '' )
Stat = utility( 'CURSOR', 'A' )
UpdatedRows = 0
if @reccount then
Stat = utility( 'CURSOR', 'H' )
open 'MODS' to ModsTable else
Void = msg( '', 'Unable to open MODS...' )
return 0
end
Eof = false$
loop
readnext Id else Eof = true$
until eof
if index( Id, 'VARDECL_', 1 ) else
ProcessErr = false$
record_lock( ModsTable, 'MODS', Id )
RowToUse = xlate( 'MODS', Id, '', 'X' )
App = field( Id, '`', 1 )
Table = field( Id, '`', 2 )
Row = field( Id, '`', 3 )
Date = field( Id, '`', 4 )
Time = field( Id, '`', 5 )
UpdateType = field( Id, '`', 6 )
begin case
case UpdateType = 'WR'
open Table to TableVar else
Void = msg( '', 'Unable to open ':Table )
return 0
end
record_lock( TableVar, Table, Row )
write RowToUse on TableVar, Row else
Void = msg( '', 'Unable to write ':Row:' on ':Table )
*return 0
ProcessErr = true$
end
unlock TableVar, Row else
Void = msg( '', 'Unable to unlock ':Row:' in ':Table )
*return 0
ProcessErr = true$
end
if Table = 'SYSPROCS' and ( not( index( Row, '_EQU', 1 ) ) ) then
recompile_proc(Row)
Err = ''
if get_status(Err) Then
Void = msg( '', 'Error while compiling ':quote(Row) )
end
end
case UpdateType = 'DR'
record_lock( TableVar, Table, Row )
delete TableVar, Row else
Void = msg( '', 'Unable to delete ':Row:' on ':Table )
*return 0
ProcessErr = true$
end
unlock TableVar, Row else
Void = msg( '', 'Unable to unlock ':Row:' in ':Table )
*return 0
ProcessErr = true$
end
end case
if ProcessErr else
delete ModsTable, Id else
Void = msg( '', 'Unable to delete ':Id:' in MODS' )
return 0
end
unlock ModsTable, Id else
Void = msg( '', 'Unable to unlock ':Id:' in MODS' )
return 0
end
UpdatedRows += 1
end
end
repeat
Stat = utility( 'CURSOR', 'A' )
MsgInfo = ''
MsgInfo<mtext$> = UpdatedRows:' rows were updated...'
MsgInfo<micon$> = '!'
Void = msg( '', MsgInfo )
Void = mods_load_control()
end else
MsgInfo = ''
MsgInfo<mtext$> = 'There are no rows in the MODS table.'
MsgInfo<micon$> = '!'
Void = msg( '', MsgInfo )
return 0
end
return 0