ристаних запитів
Вибірки з таблиці Transport
SELECT * FROM Transport Where ID IN (select TransportID FROM TransportCriterias WHERE CriteriaID= + order.FreightCriteriaID + ) and ID not in (select TransportID from Timetable Where Date = + order.Date + ) and Capacity gt;= + Order.Mass + and MinDistance lt;= + Order.Distance + and MaxDistance gt;= + Order.Distance + and InRepair=0
SELECT * FROM Transport
SELECT CriteriaID FROM TransportCriterias WHERE TransportID= + TID +
delete from TransportCriterias
INSERT INTO TransportCriterias values ??((select ID from Transport where RegNumber Like + RegNumber + ), + CriteriaID + )
SELECT ID, RegNumber FROM Transport
select distinct + TransportCrit + FROM Transport where + TransportCrit + is not null
Вибірки з таблиці Criterias
SELECT * FROM Criterias Where [Level]= + Level + order by Name
SELECT Name FROM Criterias Where ID= + ID + order by Name
select * from Criterias where Parent=(select ID from Criterias where Name like + ParentName + ) order by Name
SELECT * FROM Criterias Where Name LIKE + Name + and [Level]= + Level + order by Name
SELECT ID FROM Criterias Where [Name] LIKE + Name +
SELECT ID FROM Criterias Where [Parent]= + ParentID +
Додавання записів в таблицю Criterias
програмний база дані транзакція
insert into Criterias ([Parent], [Level], [Name]) values ??( 0 , 0 , + Name + )
insert into Criterias ([Parent], [Level], [Name]) values ??((select id from criterias where name like + Parent + ), laquo ; + Level + , + Name + )
Запити на видалення
delete from Orders where FreightCriteriaID="+ Find (Name)
delete from Criterias where [Name] like + Name +
delete from Orders where FreightCriteriaID IN (SELECT ID FROM Criterias Where Parent LIKE + ParentID + )
delete from Criterias where [Parent]= + ParentID +
delete from TransportCriterias where [CriteriaID]= + ID +
delete from Criterias where [ID]= + ID +
delete from TransportCriterias where [CriteriaID] IN (SELECT ID FROM Criterias Where Parent LIKE + ParentID + )
delete from Criterias where [Parent]= + ParentID +
delete from Criterias where [ID]= + ID +
delete from Orders where [ID]= + ID.ToString () +
delete from TimeTable where [OrderID]= + ID.ToString () +
Додавання записів в таблицю Orders
insert into orders (Supplier, Customer, Date, FreightCriteriaID, Mass, Destination, Distance) values ??( + os.Supplier + , + os.Custumer + , + os.Date.ToString () + , + os.FreightCriteriaNameID.ToString () + , + os.Mass.ToString () + raquo ;, + os.Destination + , + os.Distance + );
Додавання записів в таблицю Timetable
insert into Timetable (TransportID, OrderID, [Date]) values ??((select ID from Transport Where RegNumber= + RegNumber + ), (select MAX (ID) from Orders), + Date + );
Створення збереженої процедури пошуку
expert_db;
GOPROCEDURE FindFName varchar (20)FName=% + RTRIM (FName) + % raquo ;; * OrdersSupplier LIKEFName;
Запуск збереженої процедуриexpert_db; FindFName= а raquo ;;
Створення збереженої процедури перевірки існування
expert_dbprocedure Existance
@ Type nvarchar (100) EXISTS (SELECT * FROM Orders WHERE FreightCriteriaID=(select id from Criterias Where Name =Type))
Print Компонент існує Компонент не існує
Запуск збереженої процедури
use expert_dbExistance Комп'ютери
Створення збереженої процедури агрегування
use expert_dbprocedure sum_mass_by_supp
@ Supp varchar (50) Supplier, sum (Mass) AS Summ from Orders group by Supplier Having Supplier =Supp
Запуск збереженої процедури
expert_dbsum_mass_by_supp Владос ...