Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. create table staffreport_ispro_staff_temp as table staffreport_ispro_staff;
  2. delete from staffreport_ispro_staff_temp;
  3. alter table staffreport_ispro_staff_temp drop column id;
  4.  
  5. create table staffreport_learn_programs_temp as table staffreport_learn_programs;
  6. truncate table staffreport_learn_programs_temp;
  7.  
  8.  
  9. create table temp2 as table staffreport_ispro_staff;
  10. delete from temp2;
  11. alter table temp2 drop column id;
  12. copy temp2 from 'c:\ISPRO_StaffForLP.csv' with (FORMAT csv, ENCODING 'WIN1251', HEADER, DELIMITER ';', QUOTE '`');
  13. delete from staffreport_ispro_staff;
  14. insert into staffreport_ispro_staff (id, filial, corp_number, tabele_num, fio, position, order_n, order_date, contract_n, contract_date, protocol_n, protocol_date, science_degree, academic_rank, payroll, category, education_type, specialty, qualification, retraining, experience)
  15. select row_number() over () as rownumber,
  16. filial,
  17. corp_number,
  18. tabele_num,
  19. fio,
  20. position,
  21. order_n,
  22. order_date,
  23. contract_n,
  24. contract_date,
  25. protocol_n,
  26. protocol_date,
  27. string_agg(science_degree, ', ') as science_degree,
  28. academic_rank,
  29. payroll,
  30. category,
  31. string_agg(education_type, ', ') as education_type,
  32. string_agg(specialty, ', ') as specialty,
  33. string_agg(qualification, ', ') as qualification,
  34. string_agg(retraining, ', ') as retraining,
  35. experience
  36. from temp2
  37. group by filial, corp_number, tabele_num, fio, position, order_n,
  38. order_date, contract_n, contract_date, protocol_n,
  39. protocol_date, academic_rank, payroll, category, experience
  40. order by tabele_num;
  41. drop table temp2;
  42.  
  43.  
  44. COPY staffreport_teacher_load_temp FROM 'C:\export_TeachersLoad.dsv' WITH (FORMAT csv, HEADER, DELIMITER ';');
  45. truncate table staffreport_teacher_load;
  46. INSERT INTO staffreport_teacher_load (id, id_key, "teachertasktype$d", learnyear, learnprogram, "learnprogram$d", description, "course$d", subjectunit, "learnperiod$d", regdepartment, depcode, facdepartment, facdepartmentid, depfaculty, workerid, lastname, firstname, middlename, birthdate, "position", positioncategory, perscategory, parttime, workercode, tabelenum, depworkerid, academicstatus, "facdepcategory$d", "positioncategory$d", "teachercategory$d", "tasklevel$d", taskvalue, positionpart, resultvalue, planclass, minortype, freeplantype$d)
  47. SELECT ROW_NUMBER() OVER () as rownumber,
  48. id,
  49. "teachertasktype$d",
  50. learnyear,
  51. learnprogram,
  52. "learnprogram$d",
  53. description,
  54. "course$d",
  55. subjectunit,
  56. "learnperiod$d",
  57. regdepartment,
  58. depcode,
  59. facdepartment,
  60. facdepartmentid,
  61. depfaculty,
  62. workerid,
  63. lastname,
  64. firstname,
  65. middlename,
  66. birthdate,
  67. "position",
  68. positioncategory,
  69. perscategory,
  70. parttime,
  71. workercode,
  72. tabelenum,
  73. depworkerid,
  74. academicstatus,
  75. "facdepcategory$d",
  76. "positioncategory$d",
  77. "teachercategory$d",
  78. "tasklevel$d",
  79. taskvalue,
  80. positionpart,
  81. resultvalue,
  82. planclass,
  83. minortype,
  84. freeplantype$d
  85. FROM staffreport_teacher_load_temp;
  86. DROP TABLE staffreport_teacher_load_temp;
  87. CREATE TABLE staffreport_teacher_load_temp AS TABLE staffreport_teacher_load;
  88. truncate table staffreport_teacher_load_temp;
  89. ALTER TABLE staffreport_teacher_load_temp DROP COLUMN id;
  90. ALTER TABLE staffreport_teacher_load_temp RENAME COLUMN id_key to id;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement