-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_database_exporting_script.txt
1814 lines (1524 loc) · 66.5 KB
/
_database_exporting_script.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/******************************************************************************/
/*** Generated by IBExpert 2009.06.05 28.04.2016 12:00:14 ***/
/******************************************************************************/
/******************************************************************************/
/*** Domains ***/
/******************************************************************************/
CREATE DOMAIN NO_YES AS
VARCHAR(1)
CHECK (VALUE IN ('Y', 'N'));
/******************************************************************************/
/*** Generators ***/
/******************************************************************************/
CREATE GENERATOR GEN_LOG_FILE_ID;
SET GENERATOR GEN_LOG_FILE_ID TO 141;
CREATE GENERATOR IBE$LOG_TABLES_GEN;
SET GENERATOR IBE$LOG_TABLES_GEN TO 19;
/******************************************************************************/
/*** Exceptions ***/
/******************************************************************************/
CREATE EXCEPTION ANOUTHER_DATA '''Товар отсутствует''';
CREATE EXCEPTION ERROR 'НЕВЕРНО ВВЕДЕНЫ ДАННЫЕ!';
CREATE EXCEPTION KOL_MUST_BE_POSITIVE 'кол должно быфть больше 0';
CREATE EXCEPTION NOT_ENOUGH_GOODS 'Required more goods';
CREATE EXCEPTION WRONG_DATA_KOL_EXCEPTION '''Введено отрицательное количество''';
SET TERM ^ ;
/******************************************************************************/
/*** Stored Procedures ***/
/******************************************************************************/
CREATE PROCEDURE ADD_ORDER (
GOODS TYPE OF COLUMN TOVAR.NOMENCLATURE,
AMOUNT TYPE OF COLUMN OPERATION.KOL,
AGENT_NAME TYPE OF COLUMN AGENT.NAME_AG,
WH_NAME TYPE OF COLUMN WAREHOUSE.NAIMEN,
TYPE_OP TYPE OF COLUMN OPERATION.TYPEOP,
PRICE TYPE OF COLUMN OPERATION.PRICE,
DEL_TIME TYPE OF COLUMN DELIVERY.TIME_A,
DEL_DATE TYPE OF COLUMN OPERATION.POST_DATE,
DELIV TYPE OF COLUMN OPERATION.DELIVERY)
AS
BEGIN
EXIT;
END^
CREATE PROCEDURE AGENT_NAMES
RETURNS (
ANAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE AMOUNT_ITEM_WH (
WH_NAME TYPE OF COLUMN WAREHOUSE.NAIMEN,
NOMENCLATURE TYPE OF COLUMN TOVAR.NOMENCLATURE)
RETURNS (
AMOUNT TYPE OF COLUMN TOVAR_WH.KOL)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE CHOOSE_VEHICLE (
DEL_DATE TYPE OF COLUMN OPERATION.POST_DATE,
DEL_TIME TYPE OF COLUMN DELIVERY.TIME_A,
CAP TYPE OF COLUMN VEHICLE.CAPACITY)
RETURNS (
CAR_NUM TYPE OF COLUMN VEHICLE.NUM_V)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE COUNT_EMPTY_AGENTS
RETURNS (
"COUNT" INTEGER)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE COUNTPOST (
ID_TOV CHAR(10))
RETURNS (
CNT INTEGER)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GET_AG (
Y INTEGER)
RETURNS (
AG_NAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GET_FIRST_QARTER_AGENTS (
Y INTEGER)
RETURNS (
AGENT_NAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GET_TOV (
AG_NAME CHAR(20))
RETURNS (
TOV_NAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GET_TOVAR_BY_PRICE (
PRODUCT_PRICE INTEGER)
RETURNS (
TOVAR_NAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GET_WH (
WH_NAME CHAR(20))
RETURNS (
RET_NAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GET_WH_BY_PRODUCTS (
PRODUCT_NAME CHAR(20))
RETURNS (
WAREHOUSE_NAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GETCOUNT (
WHNAME CHAR(20))
RETURNS (
KOL INTEGER)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GETCOUNT2 (
WHNAME CHAR(20))
RETURNS (
NAIMENS CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GETNOMENLIST1 (
AGNAME CHAR(20))
RETURNS (
NOMEN CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE GETWHLIST2 (
WHNAME CHAR(20))
RETURNS (
TOVARLIST CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE ITEM_NAMES
RETURNS (
ANAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE ITEMBYCOUNT (
COU NUMERIC(15,2))
RETURNS (
TOVARNAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE ITEMS_NAMES_WH (
WH_NAME TYPE OF COLUMN WAREHOUSE.NAIMEN)
RETURNS (
NOMENCLATURE TYPE OF COLUMN TOVAR.NOMENCLATURE)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE NAME_AGENT (
KVO NUMERIC(18,2))
RETURNS (
N_AG CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE NEW_PROCEDURE (
WH_NAME TYPE OF COLUMN WAREHOUSE.NAIMEN,
DATE_FROM TYPE OF COLUMN OPERATION.POST_DATE,
DATE_TO TYPE OF COLUMN OPERATION.POST_DATE)
RETURNS (
NOMENCLATURE TYPE OF COLUMN TOVAR.NOMENCLATURE,
KOL TYPE OF COLUMN OPERATION.KOL)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE NEWTASK2 (
I CHAR(1))
RETURNS (
S VARCHAR(30))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE P1 (
TOVARNAME CHAR(20),
USER_ID CHAR(20))
AS
BEGIN
EXIT;
END^
CREATE PROCEDURE RECALCULATION
AS
BEGIN
EXIT;
END^
CREATE PROCEDURE SUM_OST (
NUM_TOVAR CHAR(10),
T_TOWN CHAR(10))
RETURNS (
SUM_OST NUMERIC(15,0))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TASK_1 (
I TYPE OF COLUMN AGENT.NAME_AG)
RETURNS (
RNAME CHAR(31))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TASK_2
RETURNS (
RNAME CHAR(31))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TASK_3 (
I TYPE OF COLUMN TOVAR.NOMENCLATURE)
RETURNS (
RNAME CHAR(31))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TASK1 (
I INTEGER)
RETURNS (
S VARCHAR(30))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TASK1_PROCEDURE (
N INTEGER)
RETURNS (
S CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TASK2 (
FROMD DATE,
TOD DATE)
RETURNS (
NOM CHAR(20),
OBOROT INTEGER)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TOV_OB (
P_YEAR INTEGER,
TOV CHAR(20))
RETURNS (
SUM1 NUMERIC(15,2))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TOVARBYAGENT (
AGENTNAME CHAR(20))
RETURNS (
TOVARNAME CHAR(20),
TOVDATE DATE)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TOVARBYDATE (
DATE1 DATE,
DATE2 DATE)
RETURNS (
TOVARNAME CHAR(20),
KOL1 NUMERIC(15,2),
KOL2 NUMERIC(15,2))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TOVARS_BY_WH (
WH_NAME TYPE OF COLUMN WAREHOUSE.NAIMEN)
RETURNS (
NOMENCLATURE TYPE OF COLUMN TOVAR.NOMENCLATURE)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE TOVARS_LESS_COST (
PRICE TYPE OF COLUMN OPERATION.PRICE)
RETURNS (
NOMENCLATURE TYPE OF COLUMN TOVAR.NOMENCLATURE)
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE WAREHOUSES (
NAIMEN CHAR(20))
RETURNS (
NAIMENS CHAR(20))
AS
BEGIN
SUSPEND;
END^
CREATE PROCEDURE WARENHOUSE_NAMES
RETURNS (
ANAME CHAR(20))
AS
BEGIN
SUSPEND;
END^
SET TERM ; ^
/******************************************************************************/
/*** Tables ***/
/******************************************************************************/
CREATE TABLE AGENT (
ID_AG CHAR(10) NOT NULL,
NAME_AG CHAR(20) NOT NULL,
ADDRESS CHAR(20) NOT NULL,
PHONE CHAR(10)
);
CREATE TABLE DELIVERY (
ID_D INTEGER NOT NULL,
ID_OP INTEGER NOT NULL,
TIME_A TIME NOT NULL,
TIME_D TIME NOT NULL,
ID_V CHAR(10) NOT NULL
);
CREATE TABLE IBE$LOG_BLOB_FIELDS (
LOG_TABLES_ID NUMERIC(18,0) NOT NULL,
FIELD_NAME VARCHAR(67) NOT NULL,
OLD_CHAR_VALUE VARCHAR(8000),
NEW_CHAR_VALUE VARCHAR(8000),
OLD_BLOB_VALUE BLOB SUB_TYPE 0 SEGMENT SIZE 80,
NEW_BLOB_VALUE BLOB SUB_TYPE 0 SEGMENT SIZE 80
);
CREATE TABLE IBE$LOG_FIELDS (
LOG_TABLES_ID NUMERIC(18,0) NOT NULL,
FIELD_NAME VARCHAR(67) NOT NULL,
OLD_VALUE VARCHAR(255),
NEW_VALUE VARCHAR(255)
);
CREATE TABLE IBE$LOG_KEYS (
LOG_TABLES_ID NUMERIC(18,0) NOT NULL,
KEY_FIELD VARCHAR(67) NOT NULL,
KEY_VALUE VARCHAR(255)
);
CREATE TABLE IBE$LOG_TABLES (
ID NUMERIC(18,0) NOT NULL,
TABLE_NAME VARCHAR(67) NOT NULL,
OPERATION VARCHAR(1) NOT NULL,
DATE_TIME TIMESTAMP NOT NULL,
USER_NAME VARCHAR(67) NOT NULL
);
CREATE TABLE INOUT (
WHNAME CHAR(20),
OPDATE DATE,
KOL NUMERIC(15,2),
SUMNUM NUMERIC(15,2),
USER_ID CHAR(20)
);
CREATE TABLE LAST_DATE (
L_DATE DATE NOT NULL
);
CREATE TABLE LIBRARY (
L_I INTEGER,
ADR VARCHAR(40),
NAME VARCHAR(20)
);
CREATE TABLE LOG_FILE (
ID INTEGER NOT NULL,
INFORM CHAR(200),
DDATA DATE
);
CREATE TABLE LOG_INFO (
ID INTEGER,
INFORM VARCHAR(200),
DDATE DATE
);
CREATE TABLE OPERATION (
ID INTEGER NOT NULL,
ID_TOVAR CHAR(10) NOT NULL,
ID_AG CHAR(10) NOT NULL,
ID_WH CHAR(10) NOT NULL,
TYPEOP CHAR(1) NOT NULL,
KOL NUMERIC(15,2) NOT NULL,
PRICE NUMERIC(15,2),
POST_DATE DATE,
DELIVERY NO_YES NOT NULL,
ORDER_DATE DATE NOT NULL
);
CREATE TABLE TOVAR (
ID_TOVAR CHAR(10) NOT NULL,
NOMENCLATURE CHAR(20) NOT NULL,
VOLUME INTEGER NOT NULL
);
CREATE TABLE TOVAR_WH (
ID INTEGER NOT NULL,
ID_WH CHAR(10) NOT NULL,
ID_TOVAR CHAR(10) NOT NULL,
KOL NUMERIC(15,2)
);
CREATE TABLE VEHICLE (
ID_V CHAR(10) NOT NULL,
NUM_V CHAR(10) NOT NULL,
CAPACITY INTEGER NOT NULL
);
CREATE TABLE WAREHOUSE (
ID_WH CHAR(10) NOT NULL,
NAIMEN CHAR(20) NOT NULL,
TOWN CHAR(10)
);
INSERT INTO AGENT (ID_AG, NAME_AG, ADDRESS, PHONE) VALUES ('A1 ', 'Reliable ', 'Azov ', '55-55-55 ');
INSERT INTO AGENT (ID_AG, NAME_AG, ADDRESS, PHONE) VALUES ('A2 ', 'OOO Partner ', 'Rostov ', '2-34-56-78 ');
INSERT INTO AGENT (ID_AG, NAME_AG, ADDRESS, PHONE) VALUES ('A3 ', 'Astra ', 'Rostov ', '2-22-22-22 ');
INSERT INTO AGENT (ID_AG, NAME_AG, ADDRESS, PHONE) VALUES ('A4 ', 'Tanais ', 'Taganrog ', '3-45-67 ');
INSERT INTO AGENT (ID_AG, NAME_AG, ADDRESS, PHONE) VALUES ('A5 ', 'OAO Leader ', 'Bataysk ', '45-45-67 ');
INSERT INTO AGENT (ID_AG, NAME_AG, ADDRESS, PHONE) VALUES ('A6 ', 'Math Institute ', 'Rostov ', '111 ');
COMMIT WORK;
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T1 ', 'Fax paper ', 10);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T2 ', 'Folders ', 5);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T3 ', 'Pencils(10 it.) ', 3);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T4 ', 'Postcard ', 1);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T5 ', 'Notebooks(12 it.) ', 2);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T6 ', 'Notepad ', 3);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T7 ', 'Souvenir-octopus ', 6);
INSERT INTO TOVAR (ID_TOVAR, NOMENCLATURE, VOLUME) VALUES ('T8 ', 'Notebook(24 sh.) ', 2);
COMMIT WORK;
INSERT INTO WAREHOUSE (ID_WH, NAIMEN, TOWN) VALUES ('С1 ', 'Alex_s Closet ', 'Frauden ');
INSERT INTO WAREHOUSE (ID_WH, NAIMEN, TOWN) VALUES ('С2 ', 'Dima_s Secret ', 'Beijing ');
INSERT INTO WAREHOUSE (ID_WH, NAIMEN, TOWN) VALUES ('С3 ', 'Random Warehouse ', 'Fobos ');
INSERT INTO WAREHOUSE (ID_WH, NAIMEN, TOWN) VALUES ('С4 ', 'God Bless ', 'Olymp ');
INSERT INTO WAREHOUSE (ID_WH, NAIMEN, TOWN) VALUES ('C5 ', 'Dima_s Warehouse ', 'Nizza ');
COMMIT WORK;
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (1, 'T1 ', 'A1 ', 'C5 ', 'R ', 5, 0, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (2, 'T1 ', 'A1 ', 'C5 ', 'R ', 5, 0, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (3, 'T1 ', 'A1 ', 'C5 ', 'R ', 5, 0, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (4, 'T1 ', 'A1 ', 'C5 ', 'R ', 5, 0, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (5, 'T1 ', 'A1 ', 'C5 ', 'R ', 5, 0, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (6, 'T1 ', 'A1 ', 'C5 ', 'R ', 5, 0, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (64, 'T7 ', 'A3 ', 'С1 ', 'A ', -500, 0, '2016-04-21', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (65, 'T7 ', 'A3 ', 'С1 ', 'A ', -500, 0, '2016-04-21', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (69, 'T2 ', 'A3 ', 'С2 ', 'R ', 100, 100, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (72, 'T2 ', 'A3 ', 'С4 ', 'R ', 40, 12, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (75, 'T3 ', 'A3 ', 'С1 ', 'R ', 100, 150, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (77, 'T3 ', 'A1 ', 'С2 ', 'R ', 100, 10, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (80, 'T2 ', 'A6 ', 'C5 ', 'R ', 50, 12, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (83, 'T8 ', 'A1 ', 'С4 ', 'R ', 36, 48, '2016-04-15', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (86, 'T2 ', 'A2 ', 'С2 ', 'A ', -49, 6, '2016-04-29', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (88, 'T2 ', 'A4 ', 'C5 ', 'A ', -16, 66, '2016-04-25', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (89, 'T2 ', 'A2 ', 'C5 ', 'A ', -9, 48, '2016-04-22', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (90, 'T2 ', 'A2 ', 'C5 ', 'A ', -9, 48, '2016-04-22', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (91, 'T2 ', 'A4 ', 'С4 ', 'R ', 54, 23, '2016-04-19', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (92, 'T8 ', 'A5 ', 'C5 ', 'R ', 52, 86, '2016-04-28', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (94, 'T8 ', 'A5 ', 'C5 ', 'R ', 43, 33, '2016-04-15', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (95, 'T8 ', 'A5 ', 'C5 ', 'R ', 41, 34, '2016-04-15', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (96, 'T2 ', 'A3 ', 'С1 ', 'R ', 65, 100, '2016-04-21', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (97, 'T1 ', 'A3 ', 'С1 ', 'R ', 1, 0, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (54, 'T2 ', 'A3 ', 'С1 ', 'R ', 50, 12, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (56, 'T2 ', 'A3 ', 'С1 ', 'A ', -50, 12, '2016-04-20', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (100, 'T3 ', 'A3 ', 'С1 ', 'R ', 72, 100, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (102, 'T1 ', 'A3 ', 'С1 ', 'R ', 1, 0, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (104, 'T1 ', 'A3 ', 'С1 ', 'R ', 1, 0, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (106, 'T1 ', 'A3 ', 'С1 ', 'R ', 10, 10, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (108, 'T2 ', 'A3 ', 'С1 ', 'R ', 1, 50, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (110, 'T2 ', 'A5 ', 'С4 ', 'R ', 100, 60, '2016-04-21', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (112, 'T1 ', 'A5 ', 'С2 ', 'A ', -36, 12, '2016-04-26', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (114, 'T6 ', 'A3 ', 'С4 ', 'R ', 1, 23, '2016-04-30', 'N', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (116, 'T8 ', 'A6 ', 'C5 ', 'A ', -103, 15, '2016-04-29', 'Y', '2016-04-25');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (118, 'T2 ', 'A3 ', 'С4 ', 'R ', 12, 12, '2016-04-28', 'Y', '2016-04-26');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (121, 'T2 ', 'A2 ', 'С4 ', 'R ', 30, 0, '2016-04-28', 'N', '2016-04-27');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (134, 'T2 ', 'A1 ', 'С3 ', 'R ', 30, 3, '2016-04-27', 'N', '2016-04-27');
INSERT INTO OPERATION (ID, ID_TOVAR, ID_AG, ID_WH, TYPEOP, KOL, PRICE, POST_DATE, DELIVERY, ORDER_DATE) VALUES (120, 'T7 ', 'A6 ', 'С1 ', 'R ', 39, 114, '2016-04-27', 'N', '2016-04-27');
COMMIT WORK;
INSERT INTO VEHICLE (ID_V, NUM_V, CAPACITY) VALUES ('V1 ', 'A111AA ', 100);
INSERT INTO VEHICLE (ID_V, NUM_V, CAPACITY) VALUES ('V2 ', 'A112AB ', 300);
INSERT INTO VEHICLE (ID_V, NUM_V, CAPACITY) VALUES ('V3 ', 'A113AC ', 50);
INSERT INTO VEHICLE (ID_V, NUM_V, CAPACITY) VALUES ('V4 ', 'A114AD ', 200);
INSERT INTO VEHICLE (ID_V, NUM_V, CAPACITY) VALUES ('V5 ', 'A115AF ', 70);
INSERT INTO VEHICLE (ID_V, NUM_V, CAPACITY) VALUES ('V6 ', 'A116AG ', 500);
COMMIT WORK;
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (1, 1, '10:00:00', '12:00:00', 'V1 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (2, 2, '10:00:00', '12:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (3, 3, '10:00:00', '12:00:00', 'V3 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (4, 4, '10:00:00', '12:00:00', 'V4 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (5, 5, '10:00:00', '12:00:00', 'V5 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (6, 6, '10:00:00', '12:00:00', 'V6 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (71, 69, '08:00:00', '10:00:00', 'V6 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (74, 72, '21:00:00', '23:00:00', 'V4 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (76, 75, '07:00:00', '09:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (79, 77, '09:00:00', '11:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (55, 54, '13:00:00', '15:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (57, 56, '16:00:00', '18:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (82, 80, '08:00:00', '10:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (85, 83, '10:00:00', '12:00:00', 'V1 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (87, 86, '11:00:00', '13:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (99, 97, '09:00:00', '11:00:00', 'V3 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (101, 100, '10:00:00', '12:00:00', 'V6 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (103, 102, '09:00:00', '11:00:00', 'V5 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (105, 104, '07:00:00', '09:00:00', 'V3 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (107, 106, '16:00:00', '18:00:00', 'V1 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (109, 108, '18:00:00', '20:00:00', 'V3 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (111, 110, '17:00:00', '19:00:00', 'V6 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (113, 112, '16:00:00', '18:00:00', 'V6 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (117, 116, '15:00:00', '17:00:00', 'V2 ');
INSERT INTO DELIVERY (ID_D, ID_OP, TIME_A, TIME_D, ID_V) VALUES (119, 118, '21:00:00', '23:00:00', 'V5 ');
COMMIT WORK;
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (3, 'ID_AG', 'p1 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (4, 'ID_AG', 'p2 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (5, 'ID_AG', 'p3 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (6, 'ID_AG', 'p4 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (7, 'ID_AG', 'p5 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (8, 'ID_AG', 'p6 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (9, 'ID_AG', 'A1 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (10, 'ID_AG', 'A2 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (11, 'ID_AG', 'A3 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (12, 'ID_AG', 'A4 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (13, 'ID_AG', 'A5 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (14, 'ID_AG', 'A6 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (15, 'ID_AG', 'A2 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (16, 'ID_AG', 'A3 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (17, 'ID_AG', 'A4 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (18, 'ID_AG', 'A5 ');
INSERT INTO IBE$LOG_KEYS (LOG_TABLES_ID, KEY_FIELD, KEY_VALUE) VALUES (19, 'ID_AG', 'A6 ');
COMMIT WORK;
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (3, 'AGENT', 'U', '2016-04-13 22:06:45', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (4, 'AGENT', 'U', '2016-04-13 22:06:51', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (5, 'AGENT', 'U', '2016-04-13 22:06:54', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (6, 'AGENT', 'U', '2016-04-13 22:06:57', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (7, 'AGENT', 'U', '2016-04-13 22:07:01', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (8, 'AGENT', 'U', '2016-04-13 22:07:06', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (9, 'AGENT', 'U', '2016-04-13 22:08:31', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (10, 'AGENT', 'U', '2016-04-14 10:19:08', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (11, 'AGENT', 'U', '2016-04-14 10:19:13', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (12, 'AGENT', 'U', '2016-04-14 10:19:19', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (13, 'AGENT', 'U', '2016-04-14 10:19:39', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (14, 'AGENT', 'U', '2016-04-14 10:21:04', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (15, 'AGENT', 'U', '2016-04-14 10:21:09', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (16, 'AGENT', 'U', '2016-04-14 10:21:12', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (17, 'AGENT', 'U', '2016-04-14 10:21:18', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (18, 'AGENT', 'U', '2016-04-14 10:21:26', 'IT39');
INSERT INTO IBE$LOG_TABLES (ID, TABLE_NAME, OPERATION, DATE_TIME, USER_NAME) VALUES (19, 'AGENT', 'U', '2016-04-14 10:21:34', 'IT39');
COMMIT WORK;
INSERT INTO LAST_DATE (L_DATE) VALUES ('2016-04-28');
COMMIT WORK;
INSERT INTO LOG_FILE (ID, INFORM, DDATA) VALUES (125, 'T2 С4 30.00 ', '2016-04-27');
INSERT INTO LOG_FILE (ID, INFORM, DDATA) VALUES (135, 'T2 С3 30.00 ', '2016-04-27');
INSERT INTO LOG_FILE (ID, INFORM, DDATA) VALUES (136, 'T2 С3 30.00 ', '2016-04-26');
INSERT INTO LOG_FILE (ID, INFORM, DDATA) VALUES (137, 'T2 С3 30.00 ', '2016-04-26');
INSERT INTO LOG_FILE (ID, INFORM, DDATA) VALUES (138, 'T2 С4 30.00 ', '2016-04-26');
INSERT INTO LOG_FILE (ID, INFORM, DDATA) VALUES (139, 'T7 С1 39.00 ', '2016-04-26');
COMMIT WORK;
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (1, 'С1 ', 'T2 ', 169);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (2, 'С1 ', 'T3 ', 228);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (3, 'С2 ', 'T1 ', 964);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (4, 'С3 ', 'T2 ', 324);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (5, 'С3 ', 'T4 ', 234);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (6, 'С3 ', 'T5 ', 1500);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (7, 'С3 ', 'T6 ', 34);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (70, 'С2 ', 'T2 ', 151);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (73, 'С4 ', 'T2 ', 642);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (115, 'С4 ', 'T6 ', 1);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (78, 'С2 ', 'T3 ', 100);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (81, 'C5 ', 'T2 ', 16);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (84, 'С4 ', 'T8 ', 36);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (93, 'C5 ', 'T8 ', 33);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (98, 'С1 ', 'T1 ', 13);
INSERT INTO TOVAR_WH (ID, ID_WH, ID_TOVAR, KOL) VALUES (141, 'С1 ', 'T7 ', 195);
COMMIT WORK;
/******************************************************************************/
/*** Primary Keys ***/
/******************************************************************************/
ALTER TABLE AGENT ADD CONSTRAINT PK_AGENT PRIMARY KEY (ID_AG);
ALTER TABLE DELIVERY ADD PRIMARY KEY (ID_D);
ALTER TABLE IBE$LOG_TABLES ADD PRIMARY KEY (ID);
ALTER TABLE LOG_FILE ADD CONSTRAINT PK_LOG_FILE PRIMARY KEY (ID);
ALTER TABLE OPERATION ADD CONSTRAINT PK_OPER PRIMARY KEY (ID);
ALTER TABLE TOVAR ADD CONSTRAINT PK_TOVAR PRIMARY KEY (ID_TOVAR);
ALTER TABLE TOVAR_WH ADD CONSTRAINT PK_TOVAR_WH PRIMARY KEY (ID);
ALTER TABLE VEHICLE ADD PRIMARY KEY (ID_V);
ALTER TABLE WAREHOUSE ADD CONSTRAINT PK_WAREHOUSE PRIMARY KEY (ID_WH);
/******************************************************************************/
/*** Foreign Keys ***/
/******************************************************************************/
ALTER TABLE DELIVERY ADD CONSTRAINT FK_DELIVERY_1 FOREIGN KEY (ID_OP) REFERENCES OPERATION (ID);
ALTER TABLE DELIVERY ADD CONSTRAINT FK_DELIVERY_2 FOREIGN KEY (ID_V) REFERENCES VEHICLE (ID_V);
ALTER TABLE OPERATION ADD CONSTRAINT FK_OP_1 FOREIGN KEY (ID_TOVAR) REFERENCES TOVAR (ID_TOVAR);
ALTER TABLE OPERATION ADD CONSTRAINT FK_OP_2 FOREIGN KEY (ID_AG) REFERENCES AGENT (ID_AG);
ALTER TABLE OPERATION ADD CONSTRAINT FK_OP_3 FOREIGN KEY (ID_WH) REFERENCES WAREHOUSE (ID_WH);
ALTER TABLE TOVAR_WH ADD CONSTRAINT FK_TOVAR_WH_1 FOREIGN KEY (ID_WH) REFERENCES WAREHOUSE (ID_WH);
ALTER TABLE TOVAR_WH ADD CONSTRAINT FK_TOVAR_WH_2 FOREIGN KEY (ID_TOVAR) REFERENCES TOVAR (ID_TOVAR);
/******************************************************************************/
/*** Indices ***/
/******************************************************************************/
CREATE INDEX IBE$LOG_BLOB_FIELDS_IDX1 ON IBE$LOG_BLOB_FIELDS (LOG_TABLES_ID);
CREATE INDEX IBE$LOG_FIELDS_IDX1 ON IBE$LOG_FIELDS (LOG_TABLES_ID);
CREATE INDEX IBE$LOG_KEYS_IDX1 ON IBE$LOG_KEYS (LOG_TABLES_ID);
/******************************************************************************/
/*** Triggers ***/
/******************************************************************************/
SET TERM ^ ;
/******************************************************************************/
/*** Database event triggers ***/
/******************************************************************************/
/* Trigger: "updated" */
CREATE TRIGGER "updated"
ACTIVE ON CONNECT POSITION 0
AS
begin
if ((select first(1) l_date from last_date) <> 'today') then
begin
execute procedure recalculation;
update last_date
set l_date = 'today';
end
end
^
/******************************************************************************/
/*** Triggers for tables ***/
/******************************************************************************/
/* Trigger: CH_OP_TWH */
CREATE TRIGGER CH_OP_TWH FOR OPERATION
ACTIVE BEFORE INSERT POSITION 0
AS
begin
if (new.typeop='A') then
if (
(select sum(o.kol)
from operation o
where o.id_tovar = new.id_tovar and o.id_wh = new.id_wh and o.order_date = 'today' )
+
(select first(1) kol
from tovar_wh
where id_tovar = new.id_tovar and id_wh = new.id_wh)
< 0
) then
exception not_enough_goods;
end
^
/* Trigger: GG */
CREATE TRIGGER GG FOR LOG_INFO
INACTIVE BEFORE INSERT POSITION 0
AS
begin
new.inform='bbb';
end
^
/* Trigger: IBE$AGENT_AU */
CREATE TRIGGER IBE$AGENT_AU FOR AGENT
ACTIVE AFTER UPDATE POSITION 32767
as
declare variable tid integer;
begin
tid = gen_id(ibe$log_tables_gen,1);
insert into ibe$log_tables (id, table_name, operation, date_time, user_name)
values (:tid, 'AGENT', 'U', 'NOW', user);
insert into ibe$log_keys (log_tables_id, key_field, key_value)
values (:tid, 'ID_AG', old.id_ag);
end
^
/* Trigger: IBE$LOG_TABLES_BD */
CREATE TRIGGER IBE$LOG_TABLES_BD FOR IBE$LOG_TABLES
ACTIVE BEFORE DELETE POSITION 0
AS
BEGIN
DELETE FROM IBE$LOG_FIELDS WHERE LOG_TABLES_ID = OLD.ID;
DELETE FROM IBE$LOG_BLOB_FIELDS WHERE LOG_TABLES_ID = OLD.ID;
DELETE FROM IBE$LOG_KEYS WHERE LOG_TABLES_ID = OLD.ID;
END
^
/* Trigger: KOL_G_Z */
CREATE TRIGGER KOL_G_Z FOR TOVAR_WH
ACTIVE AFTER INSERT OR UPDATE POSITION 0
AS
begin
if (new.kol<0) then
exception WRONG_DATA_KOL_EXCEPTION;
end
^
/* Trigger: LOG_FILE_BI */
CREATE TRIGGER LOG_FILE_BI FOR LOG_FILE
ACTIVE BEFORE INSERT POSITION 0
as
begin
if (new.id is null) then
new.id = gen_id(gen_log_file_id,1);
end
^
/* Trigger: LOG_INFO_BD0 */
CREATE TRIGGER LOG_INFO_BD0 FOR LOG_INFO
INACTIVE BEFORE DELETE POSITION 0
AS
begin
insert into log_info(inform) values (old.inform);
end
^
/* Trigger: LOG_INFO_BI0 */
CREATE TRIGGER LOG_INFO_BI0 FOR LOG_INFO
ACTIVE BEFORE INSERT POSITION 0
AS
begin
if(new.id is null) then new.id = gen_id(gen_log_file_id,1);
end
^
/* Trigger: LOG_INFO_BU0 */
CREATE TRIGGER LOG_INFO_BU0 FOR LOG_INFO
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
if (old.inform='1') then new.inform='5';
end
^
/* Trigger: NEW_ITEM */
CREATE TRIGGER NEW_ITEM FOR TOVAR_WH
ACTIVE BEFORE UPDATE POSITION 0
AS
begin
if (not exists (select * from tovar_wh where (id_wh = new.id_wh) and (id_tovar = new.id_tovar))) then
insert into tovar_wh values(gen_id(gen_log_file_id,1),new.id_wh,new.id_tovar,0);
end
^
SET TERM ; ^
/******************************************************************************/
/*** Stored Procedures ***/
/******************************************************************************/
SET TERM ^ ;
ALTER PROCEDURE ADD_ORDER (
GOODS TYPE OF COLUMN TOVAR.NOMENCLATURE,
AMOUNT TYPE OF COLUMN OPERATION.KOL,
AGENT_NAME TYPE OF COLUMN AGENT.NAME_AG,
WH_NAME TYPE OF COLUMN WAREHOUSE.NAIMEN,
TYPE_OP TYPE OF COLUMN OPERATION.TYPEOP,
PRICE TYPE OF COLUMN OPERATION.PRICE,
DEL_TIME TYPE OF COLUMN DELIVERY.TIME_A,
DEL_DATE TYPE OF COLUMN OPERATION.POST_DATE,
DELIV TYPE OF COLUMN OPERATION.DELIVERY)
AS
declare variable id integer = 0;
declare variable num char(10);
begin
id = gen_id(gen_log_file_id, 1);
if (:type_op = 'A') then
amount = :amount * (-1);
insert into operation values(
:id,
(select first(1) t.id_tovar from tovar t where t.nomenclature = :goods),
(select first(1) a.id_ag from agent a where a.name_ag = :agent_name),
(select first(1) w.id_wh from warehouse w where w.naimen = :wh_name),
:type_op,
:amount,
:price,
:del_date,
:deliv,
'today');
if (:deliv = 'Y') then
begin
execute procedure choose_vehicle(:del_date,:del_time,:amount * (select first(1) t.volume from tovar t where t.nomenclature = :goods))
returning_values :num;
insert into delivery values(
gen_id(gen_log_file_id, 1),
:id,
dateadd(hour, -1, :del_time),
dateadd(hour, 1, :del_time),
(select first(1) v.id_v from vehicle v where v.num_v = :num));
end
end^
ALTER PROCEDURE AGENT_NAMES
RETURNS (
ANAME CHAR(20))
AS
declare AGENT_CURSOR cursor for (
select NAME_AG
from AGENT);