added LSL2 stored procedures
This commit is contained in:
96
LSL2/STPROC/COPY_WORKORDER_TO_SQL.txt
Normal file
96
LSL2/STPROC/COPY_WORKORDER_TO_SQL.txt
Normal file
@ -0,0 +1,96 @@
|
||||
Compile subroutine Copy_WorkOrder_To_SQL(WorkOrderNumber)
|
||||
|
||||
/*****************************************************************************\
|
||||
This is a utility function. It copies all WO_MAT entries for a specific
|
||||
work order number.
|
||||
|
||||
History
|
||||
-------
|
||||
08/28/2013 KRF Original Programmer
|
||||
\*****************************************************************************/
|
||||
|
||||
Common /SQL_Copy_Commons/ SQL_NewRecordsOnly@
|
||||
|
||||
Equ Update_Interval$ to 500
|
||||
|
||||
If Assigned(OperationCode) else OperationCode = 0
|
||||
If Assigned(NumToCopy) else NumToCopy = 0
|
||||
Errors = ""
|
||||
|
||||
Declare function Copy_Record_To_SQL, GetTickCount, GetASyncKeyState, SRP_Com, COPY_WO_MAT_RECORD_TO_SQL
|
||||
Declare subroutine SRP_Com, RList
|
||||
|
||||
NumCopied = 0
|
||||
StartTime = GetTickCount()
|
||||
BeginTime = StartTime
|
||||
|
||||
SQL_NewRecordsOnly@ = 0
|
||||
|
||||
// Connect to the ODBC
|
||||
If SRP_Com(Connection, "CREATE", "ADODB.Connection") then
|
||||
|
||||
// Connect to the database via ODBC
|
||||
SRP_Com(Connection, "SET", "Mode", adModeShareDenyNone)
|
||||
SRP_Com(Connection, "SET", "CursorLocation", adUseClient)
|
||||
If SRP_Com(Connection, "CALL", "Open", "LSL2SQL", "srpadmin", "0okm9ijn") EQ "" then
|
||||
|
||||
Open "WO_MAT" to hTable then
|
||||
ClearSelect
|
||||
SelectStatement = "SELECT WO_MAT WITH WO_NO = ":WorkOrderNumber
|
||||
RList(SelectStatement, 5, "", "", "")
|
||||
Done = 0
|
||||
Loop
|
||||
ReadNext Key else Done = 1
|
||||
Until Done OR (GetASyncKeyState(27) LT 0)
|
||||
GoSub Copy_Key
|
||||
If NumToCopy GT 0 AND NumCopied GE NumToCopy then Done = 1
|
||||
Repeat
|
||||
end
|
||||
|
||||
end else
|
||||
Call Msg(@Window, SRP_Com(Connection, "ERROR"):@FM:@FM:@FM:"!")
|
||||
end
|
||||
|
||||
SRP_Com(Connection, "CALL", "Close")
|
||||
SRP_Com(Connection, "RELEASE")
|
||||
|
||||
end else
|
||||
Call Msg(@Window, "Unable to create ADO Object.":@FM:@FM:@FM:"!")
|
||||
end
|
||||
|
||||
Open "SYSLISTS" to hSYSLISTS then
|
||||
If Errors[-1, 1] EQ @FM then Errors[-1, 1] = ""
|
||||
If Len(Errors) then
|
||||
Write Errors to hSYSLISTS, "COPY_TABLE_TO_SQL_ERRORS*WO_MAT"
|
||||
Call SRP_Editor_Open("Record", "SYSLISTS":@FM:"COPY_TABLE_TO_SQL_ERRORS*WO_MAT")
|
||||
end else
|
||||
Delete hSYSLISTS, "COPY_TABLE_TO_SQL_ERRORS*WO_MAT" else null
|
||||
Call Msg(@Window, "No Errors")
|
||||
end
|
||||
end
|
||||
|
||||
Return
|
||||
|
||||
Copy_Key:
|
||||
|
||||
// Read the record and call the handler
|
||||
Read @RECORD from hTable, Key then
|
||||
If Key NE "" then
|
||||
Open "DICT.WO_MAT" to @DICT then null
|
||||
@ID = Key
|
||||
Error = COPY_WO_MAT_RECORD_TO_SQL(Connection, Key, @RECORD)
|
||||
end
|
||||
end
|
||||
|
||||
If Len(Error) then
|
||||
Errors := Key:@VM:Error:@FM
|
||||
end
|
||||
|
||||
NumCopied += 1
|
||||
CurrTime = GetTickCount()
|
||||
If CurrTime - StartTime GE Update_Interval$ then
|
||||
Call SRP_Editor_Send_Info("WO_MAT: ":NumCopied)
|
||||
StartTime = GetTickCount()
|
||||
end
|
||||
|
||||
return
|
Reference in New Issue
Block a user