Answer the question
In order to leave comments, you need to log in
Translate procedures and functions from oracle sql to ms sql. How?
There are 5 procedures and functions
The procedure for withdrawing a contract, its amount and by whom it was signed, as well as the client for whom it is issued.
create or replace procedure contract (num number)
is
cursor asd(num1 number)
is
select c."num_contract",c."sum",e."surname" as "empsur",cl."surname" from
"contract" c
inner join "employee" e
on c."num_employee"=e."num_employee"
inner join "clients" cl
on c."num_client"=cl."num_client"
where c."num_employee"=num1;
begin
for emp_1 in asd(num)
loop
DBMS_OUTPUT.PUT_LINE (lpad(emp_1."num_contract",20,' ')||' cost '||emp_1."sum"||' client '||emp_1."surname"|| ' emp '||emp_1."empsur" );
end loop;
end;
create or replace function allcost (num number) return number
is
vip number;
begin
select sum("sum"*0.01*"%vypl") into vip from "contract" where "num_client"=num;
return vip;
end;
create or replace procedure allcost2
is
cursor cur
is
select sum("sum"*0.01*"%vypl") "ad","num_employee"
from "contract"
group by "num_employee";
begin
for ssd in cur
loop
DBMS_OUTPUT.PUT_LINE (ssd."num_employee"||' summ '||ssd."ad");
end loop;
create or replace function pribil (num number) return number
is
vip number;
begin
select c."sum"-t."price" into vip from "contract" c
inner join "things" t
on t."thing_id"=c."thing_id"
where "num_contract"=num;
return vip;
end;
create or replace TRIGGER mol
before insert or update of "IIN" ON "clients"
for each row
DECLARE
clientsn number;
BEGIN
select count(*) into clientsn from "clients" s where s."IIN"=:new."IIN";
IF (clientsn=1) then
RAISE_APPLICATION_ERROR(-20323,'Oshibka pri vvode IIN. Nelyazya povtiryt');
end if;
end;
create or replace PACKAGE pk_client_emp as
procedure contract(num number);
function summ(num number) return number;
end pk_client_emp;
/
create or replace package body pk_client_emp
is
procedure contract(num number)
is
cursor emp(nn number)
is select c."num_contract", c."sum", cl."surname" "client", emp."surname" "employee"
from "contract" c
inner join "clients" cl
on cl."num_client"=c."num_client"
inner join "employee" emp
on emp."num_employee"=c."num_employee"
where cl."num_client"=nn;
begin
for emp1 in emp(num)
loop
DBMS_OUTPUT.PUT_LINE (emp1."num_contract"||' '||emp1."sum"||' client ='||emp1."client"|| ' employee '||emp1."employee" );
end loop;
DBMS_OUTPUT.PUT_LINE('Itogova9 summa '||summ(num));
end;
function summ(num number) return number
is
da number;
begin
select sum("sum") into da from "contract" where "num_client"=num;
return da;
end;
end pk_client_emp;
Convert at least one of them into ms sql for example
Answer the question
In order to leave comments, you need to log in
there are enough examples and specifications on MSDN
without thinking:
create function pribil (@num float)
returns float
as
begin
declare @ret float
select @ret=c.sum-t.price from "contract" c
inner join things t
on t.thing_id =c.thing_id
where [email protected]
return @ret
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question