. , , ,

,,,

,

 

, . InterBase 6.0, Borland Delphi 7.0.

.

:

-      , ;

-      ;

-      ;

-      CASE-;

-      InterBase 6.0;

-      Borland Delphi.

 


1. .

2. .

3. .

4. .

4.1. .

4.3. .

5. .

6. .

7. ( ). SQL , ,

7.1. .

7.2 .

7.3 .

7.4 .

.


1.

, .

, , . , , .


2.

- , , .

1. :

1.1.     ;

1.2.     , , ;

1.3.     , , ;

1.4.     , .

2.   :

2.1.     ;

2.2.     .

3.   :

3.1.     , ;

3.2.     , .

Borland Delphi 7.0.


3.

, , , , .

1:



1


4.

 

4.1.

, , , :

1. : , , , .

: NOMER_V

2.: , , ,

: NOMER_A

: NOMER_V.

3.: , , , .

: NOMER_K

4.: , , , .

: NOMER_M

5. : , , , , .

: NOMER_R

: NOMER_M, NOMER_A, NOMER_K

6.: , , , .

: N_ZAKAZA

: NOMER_V, NOMER_A,

4.2.

3-

1- , .. , .. . , - . , , , , , .

. , , . , 2- .

. , ( ... , 3- , , , .


5.

1)

CREATE TABLE A (

NOMER_A INTEGER NOT NULL,

MODEL VARCHAR(20),

NOMER_V INTEGER,

DATAV TIMESTAMP

)

2)

CREATE TABLE K (

NOMER_K INTEGER NOT NULL,

FAMILIA VARCHAR(20),

NAME VARCHAR(20),

OTCH VARCHAR(20)

)

3)

CREATE TABLE M (

NOMER_M INTEGER NOT NULL,

NAZVAN VARCHAR(20),

PROT INTEGER,

SRTIME INTEGER

)

4)

CREATE TABLE R (

NOMER_R INTEGER NOT NULL,

DATAOTPR TIMESTAMP,

NOMER_M INTEGER,

NOMER_K INTEGER,

NOMER_A INTEGER

)

5)

CREATE TABLE TECH_OSMOTR (

NOMER_TO INTEGER NOT NULL,

DATETO TIMESTAMP NOT NULL,

REZULT VARCHAR(50),

NOMER_V INTEGER,

NOMER_A INTEGER

)

6)

CREATE TABLE V (

NOMER_V INTEGER NOT NULL,

FAMILIA VARCHAR(20),

NAME VARCHAR(20),

OTCH VARCHAR(20)

)


6.

 

:

CREATE TRIGGER INS_A FOR A BEFORE INSERT POSITION 0 as declare variable cn integer;

begin

select max(nomer_a) from a into :cn;

if (cn is null) then new.nomer_a=1;

else

new.nomer_a=cn+1;

end

:

CREATE TRIGGER INS_K FOR K BEFORE INSERT POSITION 0 as declare variable cn integer;

begin

select max(nomer_k) from k into :cn;

if (cn is null) then new.nomer_k=1;

else

new.nomer_k=cn+1;

end

:

CREATE TRIGGER INS_M FOR M BEFORE INSERT POSITION 0 as declare variable cn integer;

begin

select max(nomer_m) from m into :cn;

if (cn is null) then new.nomer_m=1;

else

new.nomer_m=cn+1;

end

:

CREATE TRIGGER INS_TO FOR TECH_OSMOTR BEFORE INSERT POSITION 0 as declare variable cn integer;

begin

select max(nomer_to) from tech_osmotr into :cn;

if (cn is null) then new.nomer_to=1;

else

new.nomer_to=cn+1;

end

:

CREATE TRIGGER INS_V FOR V BEFORE INSERT POSITION 0 as declare variable cn integer;

begin

select max(nomer_v) from v into :cn;

if (cn is null) then new.nomer_v=1;

else

new.nomer_v=cn+1;

end


7. ( ). SQL , ,

 

. , .

7.1.

 

, : " ", " ", , , , .


" " , .

" " , .

" " , .

" " .

" " , .

" " , .

 

7.2

, 5.

" " . . .

SQL :

Select M.NAZVAN, R.DATAOTPR from M,R

SQL :

Select M.NAZVAN, R.DATAOTPR from M,R' );

where M.NOMER_M=R.NOMER_M and R.DATAOTPR>='+''''+edit1.Text+''''+'

and R.DATAOTPR<='+''''+edit2.text+''''

" " . , .

.

SQL :

Select a.model, nazvan ,prot

from A,V,m,R

where a.NOMER_V=V.NOMER_V and M.NOMER_M=R.NOMER_M and a.NOMER_a=R.NOMER_a

 

SQL :

QUERY1.CLOSE;

QUERY1.SQL.CLEAR;

QUERY1.SQL.ADD('Select a.model,nazvan ,prot from A,V,m,R' );

QUERY1.SQL.ADD('where a.NOMER_V=V.NOMER_V and M.NOMER_M=R.NOMER_M and a.NOMER_a=R.NOMER_a and model='+''''+edit1.Text+'''') ;

QUERY1.open;

. , .


SQL :

Select distinct a.model,sum(PROT) from A,V,m,R

where a.NOMER_V=V.NOMER_V and M.NOMER_M=R.NOMER_M and a.NOMER_a=R.NOMER_a group by model

" " . , . .

SQL :

Select M.NAZVAN, R.DATAOTPR, K.FAMILIA , v.familia from M,R,K, v,a

where M.NOMER_M=R.NOMER_M and

K.nomer_k=R.NOMER_K and a.nomer_a=r.NOMER_a and a.nomer_v=a.NOMER_a

and v.familia like :fv and k.familia like :fk

SQL :

procedure TForm12.Button1Click(Sender: TObject);

begin

QUERY1.CLOSE;

QUERY1.ParamByName('fk').value:=Edit1.Text+'%';

QUERY1.ParamByName('fv').value:=Edit2.Text+'%';

QUERY1.open;

end;

SQL :

procedure TForm12.FormActivate(Sender: TObject);

begin

QUERY1.CLOSE;

QUERY1.ParamByName('fk').value:='%';

QUERY1.ParamByName('fv').value:='%';

QUERY1.open;

end;

" " . , . .

SQL :

Select a.model, TECH_OSMOTR.dateto, TECH_OSMOTR.rezult, v.familia from TECH_OSMOTR, v,a

where

TECH_OSMOTR.nomer_v=v.Nomer_v and TECH_OSMOTR.nomer_a=a.nomer_a and a.model like :m


SQL :

procedure TForm18.Button1Click(Sender: TObject);

begin

form18.query1.close;

form18.QUERY1.ParamByName('m').value:=Edit1.Text+'%';

form18.query1.open;

end;

Select a.model, TECH_OSMOTR.dateto, TECH_OSMOTR.rezult, v.familia from TECH_OSMOTR, v,a

where

TECH_OSMOTR.nomer_v=v.Nomer_v and TECH_OSMOTR.nomer_a=a.nomer_a and v.familia like :f


procedure TForm20.Button1Click(Sender: TObject);

begin

form20.query1.close;

form20.QUERY1.ParamByName('f').value:=Edit1.Text+'%';

form20.query1.open;

end;

, , .

:

Select v.familia, count(v.familia) from TECH_OSMOTR, v,a

where TECH_OSMOTR.nomer_v=v.Nomer_v and TECH_OSMOTR.nomer_a=a.nomer_a

group by v.familia

7.3

 

, .

. ( ).

. .

:

Select familia, count(familia) from M,R,K, v,a

where M.NOMER_M=R.NOMER_M and

K.nomer_k=R.NOMER_K and a.nomer_a=r.NOMER_a and v.nomer_v=a.NOMER_v and

dataotpr>=:d1 and dataotpr<=:d2

group by v.familia


Select model, count(model) from M,R,K, v,a

where M.NOMER_M=R.NOMER_M and

K.nomer_k=R.NOMER_K and a.nomer_a=r.NOMER_a and v.nomer_v=a.NOMER_v and

dataotpr>=:d1 and dataotpr<=:d2

group by a.model

gr1.query1.close;

gr1.QUERY1.ParamByName('d1').asDate:=DateTimePicker1.Date;

gr1.QUERY1.ParamByName('d2').asDate:=DateTimePicker2.Date;

gr1.query1.open;

gr1.query3.close;

gr1.QUERY3.ParamByName('d1').asDate:=DateTimePicker1.Date;

gr1.QUERY3.ParamByName('d2').asDate:=DateTimePicker2.Date;

gr1.query3.open;

 

7.4 .

.

, .

SQL :

select v.familia, k.familia from k, v,a,r

where

K.nomer_k=R.NOMER_K and a.nomer_a=r.NOMER_a and a.nomer_v=v.NOMER_v

group by v.familia, k.familia

.

 

:

Select M.NAZVAN, R.DATAOTPR from M,R

where M.NOMER_M=R.NOMER_M and

dataotpr>=:d1 and dataotpr<=:d2

form17.query1.close;

form17.QUERY1.ParamByName('d1').asDate:=DateTimePicker1.Date;

form17.QUERY1.ParamByName('d2').asDate:=DateTimePicker2.Date;

form17.query1.open;

form16.query1.close;

form16.QUERY1.ParamByName('d1').asDate:=DateTimePicker1.Date;

form16.QUERY1.ParamByName('d2').asDate:=DateTimePicker2.Date;

form16.query1.open;

form16.quickrep1.preview;


 

. , , .

, , .

, Borland Delphi 7.0 Inter Base 6.0 SQL Explorer, SQL, .

, . InterBase 6.0,

 

 

 

! , , , .
. , :