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

70 lines
1.9 KiB
Plaintext

compile function mssql_checkdata( Row, ConfigRecID, ConfigRec, ConfigTable )
declare function fieldcount, msg
$insert logical
convert '`' to @fm in Row
ThisRowID = Row<1>
Rcnt = fieldcount( Row, @fm )
NewRow = ''
for i = 1 to Rcnt
ThisColumn = Row<i>
ColRule = ConfigRec<i>
convert '`' to @fm in ColRule
DataType = ColRule<1>
DataSpec = ColRule<2>
DataSpec2 = ColRule<3>
begin case
case DataType = 'V'
if len( ThisColumn ) > DataSpec then
gosub WriteErr
return 1
end
case DataType = 'I'
if index( ThisColumn, '.', 1 ) then
gosub WriteErr
return 1
end else
if num( ThisColumn ) else
gosub WriteErr
return 1
end
end
case DataType = 'DT'
ThisColumn = oconv( ThisColumn, 'D2/' )
case DataType = 'D'
ThisColumn = oconv( ThisColumn, 'MD':DataSpec2 )
if len(field( ThisColumn, '.', 1 )) > DataSpec then
gosub WriteErr
return 1
end
case DataType = 'T'
if index( ThisColumn, '`', 1 ) then
gosub WriteErr
return 1
end
case DataType = 'C'
if len( ThisColumn ) = DataSpec else
gosub WriteErr
return 1
end
end case
NewRow := ThisColumn:'`'
next i
NewRow[-1,1] = ''
Row = NewRow
return 0
*================================================================================================*
WriteErr:
ErrorRecID = ConfigRecID:'_ERR'
ErrorLine = fmt( ThisRowId, 'R#15' ):' ':i: ' ':ThisColumn
ErrorRec = xlate( 'CONFIG', ErrorRecID, '', 'X' )
ErrorRec<-1> = ErrorLine
write ErrorRec on ConfigTable, ErrorRecID else
Void = msg( '', 'Error writing ':ErrorRecID:' on CONFIG...' )
return 0
end
return
*================================================================================================*