Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Архив / Denisov_S_I_UAI-511_Diplom_Versia_FINAL_NAYa.doc
Скачиваний:
78
Добавлен:
09.06.2015
Размер:
8.36 Mб
Скачать

Автопредставитель (Autorepr)

begin

-- Сперва удалим того представителя

delete from representatives_ r

where r.id_contract = %p1[i]%

and r.id_represented = (Select c.id_who From contracts_ c Where c.id_contract = %p1[i]%)

and r.d_start = (Select c.d_start From contracts_ c Where c.id_contract = %p1[i]%);

-- Потом - добавим нового

insert into representatives_ r

(id_contract,

id_represented,

id_representative,

d_start,

id_paragraph,

power_of_attorney,

id_post)

(select c.id_contract,

c.id_who,

emp.id_contractor,

c.d_start,

c.id_paragraph,

nvl((Select'доверенности от ' ||

to_char(doc.when_given, 'dd.mm.yyyy') || 'г. № ' ||

doc.identifier

From documents_ doc, kind_document_ kd

Where kd.idk_doc = doc.idk_doc

and doc.idk_doc = 26

and doc.id_e = emp.id_e

and doc.when_given =

(Select max(d.when_given)

From documents_ d

Where d.idk_doc = doc.idk_doc

and d.id_e = doc.id_e

and d.when_given <= sysdate)

andrownum= 1),

'Устава университета'),

pc.id_post

from contracts_ c,

paragraphs_ p,

who_signed_ ws,

staff_ st,

employees_ emp,

units_staff_ us,

posts_categories_ pc

where c.id_contract = %p1[i]%

and c.id_paragraph = p.id_paragraph

and p.idk_order >= 400

and p.id_order = ws.id_order

and ws.id_staff = st.id_staff

and ws.index_record = 1

and emp.id_e = st.id_e

and st.id_units = us.id_units

and us.idg_post = pc.idg_post

and rownum = 1);

end;

Виды договоров (Kind_Order)

Select ko.Name

,ko.idk_order

From kind_order_ ko

Where ko.idk_order = 68924

Виды направлений (Kind_Direction)

Select ko.Name, ko.idk_order

From kind_order_ ko

Where ko.idk_order In (431, 433, 434, 62)

Добавить направление (Add_Direction)

Insert Into Accounts_Contract_

(Id_Paragraph, Id_Stage, Money, d_Start, d_End)

(Select %p1[i]%

,s.id_stage

,s.money

,s.d_start

,s.d_end

From Stages_ s

Where s.id_contract = %p2[i]%)

Добавление договора (Add_Contract)

Declare

id_c Number;

Begin

-- Договор

Insert Into contracts_

(id_with_whom, id_who, d_start, d_end, id_paragraph, id_source)

Values

((Select e.id_contractor From employees_ e Where e.id_e = %p1[i]%)

,(Select o.id_contractor

From values_setup_ vs

,organizations_ o

Where vs.id_manual = 100

And vs.Value = o.id_organization

And vs.d_start =

(Select Max(vs2.d_start)

From values_setup_ vs2

Where vs2.d_start <= Sysdate

And vs2.id_manual = vs.id_manual))

,%p3[d]%

,%p4[d]%

,%p5[i]%

,%p6[i]%)

Returning id_contract Into id_c;

-- Этап с суммой

Insert Into stages_

(id_contract, id_paragraph, d_start, d_end, d_opening, subject, money, identifier)

Values

(id_c

,%p5[i]%

,%p3[d]%

,%p4[d]%

,%p3[d]%

,'Повышение квалификации'

,%p11[s]%

,1);

Insert Into contract_sources_

(id_contract, id_type_value, id_source, d_start, Value)

Values

(id_c, 2, %p6[i]%, %p3[d]%, 100);

Insert Into specialities_contract_

(id_contract, id_d_specialitie, idk_status_trainee, d_start)

Values

(id_c, %p7[i]%, 1, %p3[d]%);

-- Представитель студента - организация

If%p2[i]%isnotnull

Then

Insert Into representatives_ r

(id_contract

,id_represented

,id_representative

,d_start

,id_paragraph

,r.power_of_attorney

,r.representative_organization

,r.representative_organization_r

,r.id_post)

Select c.id_contract

,c.id_with_whom

,%p2[i]%

,%p3[d]%

,c.id_paragraph

,%p13[s]%

,%p14[s]%

,%p15[s]%

,%p16[i]%

From contracts_ c

Where c.id_contract = id_c;

EndIf;

-- Представитель МИИТа по первой подписи в договоре

Insert Into representatives_ r

(id_contract

,id_represented

,id_representative

,d_start

,id_paragraph

,power_of_attorney

,id_post)

(Select c.id_contract

,c.id_who

,emp.id_contractor

,c.d_start

,c.id_paragraph

,nvl((Select 'доверенности от ' ||

to_char(doc.when_given, 'dd.mm.yyyy') || 'г. № ' ||

doc.identifier

From documents_ doc

,kind_document_ kd

Where kd.idk_doc = doc.idk_doc

And doc.idk_doc = 26

And doc.id_e = emp.id_e

And doc.when_given =

(Select Max(d.when_given)

From documents_ d

Where d.idk_doc = doc.idk_doc

And d.id_e = doc.id_e

And d.when_given <= Sysdate)

Andrownum= 1)

,'Устава университета')

,pc.id_post

From contracts_ c

,paragraphs_ p

,who_signed_ ws

,staff_ st

,employees_ emp

,units_staff_ us

,posts_categories_ pc

Where c.id_contract = id_c

And c.id_paragraph = p.id_paragraph

And p.idk_order >= 400

And p.id_order = ws.id_order

And ws.id_staff = st.id_staff

And ws.index_record = 1

And emp.id_e = st.id_e

And st.id_units = us.id_units

And us.idg_post = pc.idg_post

And rownum = 1);

If %p12[s]% is not null

Then

Update students_ s Set s.id_order_contract = %p5[i]% Where s.id_student = %p12[s]% ;

End if;

End;

Соседние файлы в папке Архив