Π—Π°ΠΊΠ°Π·Π°Ρ‚ΡŒ курсовыС, ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»ΡŒΠ½Ρ‹Π΅, Ρ€Π΅Ρ„Π΅Ρ€Π°Ρ‚Ρ‹...
ΠžΠ±Ρ€Π°Π·ΠΎΠ²Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ Ρ€Π°Π±ΠΎΡ‚Ρ‹ Π½Π° Π·Π°ΠΊΠ°Π·. НСдорого!

Π‘ΠΊΡ€ΠΈΠΏΡ‚ ΠΏΠΎ созданию Ρ…Ρ€Π°Π½ΠΈΠΌΡ‹Ρ… ΠΏΡ€ΠΎΡ†Π΅Π΄ΡƒΡ€

Π Π΅Ρ„Π΅Ρ€Π°Ρ‚ΠŸΠΎΠΌΠΎΡ‰ΡŒ Π² Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΠΈΠ£Π·Π½Π°Ρ‚ΡŒ ΡΡ‚ΠΎΠΈΠΌΠΎΡΡ‚ΡŒΠΌΠΎΠ΅ΠΉ Ρ€Π°Π±ΠΎΡ‚Ρ‹

DECLARE VARIABLE discount INTEGER; WHERE c. id_client=:id_client; CREATE PROCEDURE view_address. CREATE PROCEDURE not_executed. DECLARE VARIABLE summa money; SET c. discount = :discount. Apartament_number transfer). GROUP BY o. id_client. INTO: id_client:summa. AND o. executed = '0'. UPDATE client c. Discount = '0'; FROM orders o. Set term ;!! Set term !!; Suspend; Suspend; Begin. Begin. Begin… Π§ΠΈΡ‚Π°Ρ‚ΡŒ Π΅Ρ‰Ρ‘ >

Π‘ΠΊΡ€ΠΈΠΏΡ‚ ΠΏΠΎ созданию Ρ…Ρ€Π°Π½ΠΈΠΌΡ‹Ρ… ΠΏΡ€ΠΎΡ†Π΅Π΄ΡƒΡ€ (Ρ€Π΅Ρ„Π΅Ρ€Π°Ρ‚, курсовая, Π΄ΠΈΠΏΠ»ΠΎΠΌ, ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»ΡŒΠ½Π°Ρ)

Π’ Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ… Π½Π΅ΠΎΠ±Ρ…ΠΎΠ΄ΠΈΠΌΠΎ ΡΠΎΠ·Π΄Π°Ρ‚ΡŒ ΡΠ»Π΅Π΄ΡƒΡŽΡ‰ΠΈΠ΅ Ρ…Ρ€Π°Π½ΠΈΠΌΡ‹Π΅ ΠΏΡ€ΠΎΡ†Π΅Π΄ΡƒΡ€Ρ‹:

  • 1. ВывСсти всС Π½Π΅ΠΏΠΎΠ³Π°ΡˆΠ΅Π½Π½Ρ‹Π΅ Π·Π°ΠΊΠ°Π·Ρ‹ вмСстС с Ρ‚ΠΎΠ²Π°Ρ€ΠΎΠΌ, ΠΈΡ… ΠΊΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎΠΌ ΠΈ ΡΠΎΡ‚Ρ€ΡƒΠ΄Π½ΠΈΠΊΠΎΠ² ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈΡ… Π²Ρ‹ΠΏΠΎΠ»Π½ΡΡŽΡ‚.
  • 2. РасчСт ΠΈ Π·Π°Π½Π΅ΡΠ΅Π½ΠΈΠ΅ скидки для ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° Π² Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡ‚ΠΈ ΠΎΡ‚ ΡΡƒΠΌΠΌΡ‹ ΠΏΠΎΡ‚Ρ€Π°Ρ‡Π΅Π½Π½ΠΎΠΉ ΠΈΠΌ Π½Π° Ρ‚ΠΎΠ²Π°Ρ€Ρ‹.
  • 3. ВывСсти Π³ΠΎΡ€ΠΎΠ΄, ΡƒΠ»ΠΈΡ†Ρƒ, Π΄ΠΎΠΌ, ΠΊΠ²Π°Ρ€Ρ‚ΠΈΡ€Ρƒ, ΠΈ Ρ‡Π΅Π»ΠΎΠ²Π΅ΠΊΠ° ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΠΏΡ€ΠΎΠΆΠΈΠ²Π°Π΅Ρ‚ ΠΏΠΎ Π΄Π°Π½Π½ΠΎΠΌΡƒ адрСсу.

/************************************************************/.

/*ВывСсти всС Π½Π΅ΠΏΠΎΠ³Π°ΡˆΠ΅Π½Π½Ρ‹Π΅ Π·Π°ΠΊΠ°Π·Ρ‹ вмСстС с Ρ‚ΠΎΠ²Π°Ρ€ΠΎΠΌ, ΠΈΡ… ΠΊΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎΠΌ ΠΈ ΡΠΎΡ‚Ρ€ΡƒΠ΄Π½ΠΈΠΊΠΎΠ² ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ ΠΈΡ… Π²Ρ‹ΠΏΠΎΠ»Π½ΡΡŽΡ‚ */.

/************************************************************/.

/*Π’Π²ΠΎΠ΄ΠΈΠΌ ΠΏΠΎΠ»Π΅ «ΠΏΠΎΠ³Π°ΡˆΠ΅Π½ΠΎ» Π² Ρ‚Π°Π±Π»ΠΈΡ†Ρƒ Π·Π°ΠΊΠ°Π·*/.

ALTER TABLE orders ADD executed INTEGER CHECK ((executed IN (0,1)) and (executed is not null));

/*Π²Π²ΠΎΠ΄ΠΈΠΌ для ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° ΠΏΠΎΠ»Π΅ скидка*/.

ALTER TABLE client ADD discount INTEGER DEFAULT 0 CHECK (discount IS NOT NULL);

SET TERM !!;

CREATE PROCEDURE not_executed.

RETURNS (id_order INTEGER, name VARCHAR (20), quantity INTEGER,.

manager VARCHAR (20), seller VARCHAR (20), forwarding_agent VARCHAR (20), driver VARCHAR (20)).

AS.

BEGIN.

FOR.

SELECT o. id_order, r. quantity, g.name,.

  • (SELECT e. fio FROM employee e WHERE e. id_employee=o.manager) AS manager,
  • (SELECT e. fio FROM employee e WHERE e. id_employee=o.seller) AS seller,
  • (SELECT e. fio FROM employee e WHERE e. id_employee=d.forwarding_agent) AS forwarding_agent,
  • (SELECT e. fio FROM employee e WHERE e. id_employee=d.driver) AS driver

FROM orders o, row_order r, goods g, row_delivery rd, delivery d.

WHERE r. id_order=o.id_order AND r. id_goods=g.id_goods AND rd. id_order=o.id_order AND d. id_delivery=rd.id_delivery.

AND o. executed = '0'.

INTO :id_order:quantity:name:manager:seller:forwarding_agent:driver.

DO.

SUSPEND;

END!

/************************************************************/.

/*РасчСт ΠΈ Π·Π°Π½Π΅ΡΠ΅Π½ΠΈΠ΅ скидки для ΠΊΠ»ΠΈΠ΅Π½Ρ‚Π° Π² Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡ‚ΠΈ ΠΎΡ‚ ΡΡƒΠΌΠΌΡ‹ ΠΏΠΎΡ‚Ρ€Π°Ρ‡Π΅Π½Π½ΠΎΠΉ ΠΈΠΌ Π½Π° Ρ‚ΠΎΠ²Π°Ρ€Ρ‹ */.

/************************************************************/.

CREATE PROCEDURE calculate_discount.

AS.

DECLARE VARIABLE id_client INTEGER;

DECLARE VARIABLE summa money;

DECLARE VARIABLE discount INTEGER;

BEGIN.

FOR.

SELECT o. id_client, SUM (o.cost).

FROM orders o.

GROUP BY o. id_client.

INTO :id_client:summa.

DO.

BEGIN.

IF (:summa>'3000') THEN discount = '5'; ELSE.

IF ((:summa'3000')) THEN discount = '7'; ELSE.

IF (:summa>'10 000') THEN discount = '10'; ELSE.

discount = '0';

UPDATE client c.

SET c. discount = :discount.

WHERE c. id_client=:id_client;

END.

END!

/************************************************************/.

/*ВывСсти Π³ΠΎΡ€ΠΎΠ΄, ΡƒΠ»ΠΈΡ†Ρƒ, Π΄ΠΎΠΌ, ΠΊΠ²Π°Ρ€Ρ‚ΠΈΡ€Ρƒ, ΠΈ Ρ‡Π΅Π»ΠΎΠ²Π΅ΠΊΠ° ΠΊΠΎΡ‚ΠΎΡ€Ρ‹ΠΉ ΠΏΡ€ΠΎΠΆΠΈΠ²Π°Π΅Ρ‚ ΠΏΠΎ Π΄Π°Π½Π½ΠΎΠΌΡƒ адрСсу*/.

/************************************************************/.

CREATE PROCEDURE view_address.

returns (fio varchar (20), city_name varchar (20), street_name varchar (20), house_number transfer,.

apartament_number transfer).

AS.

BEGIN.

FOR.

SELECT c. fio, ci. city_name, s. street_name, a. house_number, a. apartament_number.

FROM client c, address a, city ci, street s.

WHERE c. id_address=a.id_address AND a. id_city=ci.id_city AND a. id_street=s.id_street.

INTO :fio:city_name:street_name:house_number:apartament_number.

DO.

suspend;

END!

SET TERM ;!!

ΠŸΠΎΠΊΠ°Π·Π°Ρ‚ΡŒ вСсь тСкст
Π—Π°ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ Ρ„ΠΎΡ€ΠΌΡƒ Ρ‚Π΅ΠΊΡƒΡ‰Π΅ΠΉ Ρ€Π°Π±ΠΎΡ‚ΠΎΠΉ