@@ -16,6 +16,9 @@ import Synergex.SynergyDE.Select
1616.include "EMPLOYEE" repository, structure="strEmployee", end
1717.endc
1818
19+ .define writelog(x) if ^passed(a_logchannel) && a_logchannel && %chopen(a_logchannel) writes(a_logchannel,%string(^d(now(1:14)),"XXXX-XX-XX XX:XX:XX ") + x)
20+ .define writett(x) if ^passed(a_ttchannel) && a_ttchannel writes(a_ttchannel," - " + %string(^d(now(9:8)),"XX:XX:XX.XX ") + x)
21+
1922;;*****************************************************************************
2023;;; <summary>
2124;;; Determines if the Employee table exists in the database.
@@ -331,8 +334,6 @@ function EmployeeIndex, ^val
331334 sql ,string ;;SQL statement
332335 endrecord
333336
334- .define writelog(x) writes(a_logchannel," - " + %string(^d(now(9:8)),"XX:XX:XX.XX ") + x)
335-
336337proc
337338 init local_data
338339 ok = true
357358 if (ok)
358359 begin
359360 now = %datetime
360- writelog("Setting database timeout to " + %string(a_bl_timeout) + " seconds")
361+ writelog(" - Setting database timeout to " + %string(a_bl_timeout) + " seconds")
361362 if (%ssc_cmd(a_dbchn,,SSQL_TIMEOUT,%string(a_bl_timeout))==SSQL_FAILURE)
362363 begin
363364 ok = false
370371
371372 if (ok && !%IndexExists(a_dbchn,"IX_Employee_EmpDept",errtxt))
372373 begin
373- now = %datetime
374- writelog(" - Adding index IX_Employee_EmpDept")
375-
376374 sql = 'CREATE INDEX IX_Employee_EmpDept ON "Employee"("EmpDept" ASC)'
377375
378376 call open_cursor
@@ -382,15 +380,24 @@ proc
382380 call execute_cursor
383381 call close_cursor
384382 end
383+
384+ now = %datetime
385+
386+ if (ok) then
387+ begin
388+ writelog(" - Added index IX_Employee_EmpDept")
389+ end
390+ else
391+ begin
392+ writelog(" - ERROR: Failed to add index IX_Employee_EmpDepts")
393+ ok = true
394+ end
385395 end
386396
387397 ;;Create index 2 (Last name)
388398
389399 if (ok && !%IndexExists(a_dbchn,"IX_Employee_EmpLastName",errtxt))
390400 begin
391- now = %datetime
392- writelog(" - Adding index IX_Employee_EmpLastName")
393-
394401 sql = 'CREATE INDEX IX_Employee_EmpLastName ON "Employee"("EmpLastName" ASC)'
395402
396403 call open_cursor
@@ -400,15 +407,24 @@ proc
400407 call execute_cursor
401408 call close_cursor
402409 end
410+
411+ now = %datetime
412+
413+ if (ok) then
414+ begin
415+ writelog(" - Added index IX_Employee_EmpLastName")
416+ end
417+ else
418+ begin
419+ writelog(" - ERROR: Failed to add index IX_Employee_EmpLastNames")
420+ ok = true
421+ end
403422 end
404423
405424 ;;Create index 3 (State)
406425
407426 if (ok && !%IndexExists(a_dbchn,"IX_Employee_StateCode",errtxt))
408427 begin
409- now = %datetime
410- writelog(" - Adding index IX_Employee_StateCode")
411-
412428 sql = 'CREATE INDEX IX_Employee_StateCode ON "Employee"("EmpAddressState" ASC)'
413429
414430 call open_cursor
@@ -418,15 +434,24 @@ proc
418434 call execute_cursor
419435 call close_cursor
420436 end
437+
438+ now = %datetime
439+
440+ if (ok) then
441+ begin
442+ writelog(" - Added index IX_Employee_StateCode")
443+ end
444+ else
445+ begin
446+ writelog(" - ERROR: Failed to add index IX_Employee_StateCodes")
447+ ok = true
448+ end
421449 end
422450
423451 ;;Create index 4 (Zip code)
424452
425453 if (ok && !%IndexExists(a_dbchn,"IX_Employee_ZipCode",errtxt))
426454 begin
427- now = %datetime
428- writelog(" - Adding index IX_Employee_ZipCode")
429-
430455 sql = 'CREATE INDEX IX_Employee_ZipCode ON "Employee"("EmpAddressZip" ASC)'
431456
432457 call open_cursor
@@ -436,6 +461,18 @@ proc
436461 call execute_cursor
437462 call close_cursor
438463 end
464+
465+ now = %datetime
466+
467+ if (ok) then
468+ begin
469+ writelog(" - Added index IX_Employee_ZipCode")
470+ end
471+ else
472+ begin
473+ writelog(" - ERROR: Failed to add index IX_Employee_ZipCodes")
474+ ok = true
475+ end
439476 end
440477
441478
470507 ;;Set the database timeout back to the regular value
471508
472509 now = %datetime
473- writelog("Resetting database timeout to " + %string(a_db_timeout) + " seconds")
510+ writelog(" - Resetting database timeout to " + %string(a_db_timeout) + " seconds")
474511 if (%ssc_cmd(a_dbchn,,SSQL_TIMEOUT,%string(a_db_timeout))==SSQL_FAILURE)
475512 nop
476513
@@ -2204,9 +2241,6 @@ function EmployeeBulkLoad, ^val
22042241 now, a20
22052242 endrecord
22062243
2207- .define writelog(x) writes(a_logchannel," - " + %string(^d(now(9:8)),"XX:XX:XX.XX ") + x)
2208- .define writett(x) if ^passed(a_ttchannel) && a_ttchannel writes(a_ttchannel," - " + %string(^d(now(9:8)),"XX:XX:XX.XX ") + x)
2209-
22102244proc
22112245
22122246 init local_data
0 commit comments