Вы находитесь на странице: 1из 48

13

.

. Web
HTML-.
.1 ,
.

.1.
:

<FORM>

<INPUT TYPE>

<SUBMIT>

<RESET>
<form> action, ,
1

-, ,

:
<FORM ACTION=URL METHOD ENCTYPE=_>.
, ,
, Email , : action=mailto: geoton@narod.ru
<form> - method ,

.
Web .
:
1.

GET

2.

POST

GET,
URL, ?.
,
POST.

<form action=mailto: geoton@narod.ru method=post>


</form>
GET,
GET /bhv.ru/cgi-bin/prog1.gi ? NAME=stive&format=HTML HTTP/1.0
Input:
, ,
..
<INPUT TYPE: __ NAME=__
>

TYPE:

TEXT

PASSWORD *

CHECKBOX

.
.

RADIO ,

RESET .

SUBMIT .

.
<FORM>

<INPUT TYPE: text NAME=My Value= SIZE=10 MAX
LENGTH=20>
.
<FORM>

<INPUT TYPE: password NAME=posst Value= SIZE=20 MAX
LENGTH=30>
.

.2.
<HTML>
<HEAD>
<TITLE> </TITLE>
</HEAD>
<BODY>
<H1> ?</H1>
<P>
<BR>
<FORM METHOD=POST ACTION=Tbindwio>
: <BR>
<INPUT TYPE=text NAME=FIO SIZE=20 MAX_LENGTH=40>
: <BR>
<INPUT TYPE=text NAME=IMY SIZE=20 MAX_LENGTH=40>
<P>
<INPUT TYPE=SUBMIT VALUE=>
<INPUT TYPE=RESET VALUE=>
</FORM>
</HTML>
:
RADIO:
4

<UL>
<INPUT TYPE=RADIO NAME=cord1 VALUE=
CHECKED>
<INPUT TYPE=RADIO NAME=cord2 VALUE=>
<INPUT TYPE=RADIO NAME=cord3 VALUE=>
</UL>
:

CHECKBOX:
<UL>
<INPUT TYPE= CHECKBOX NAME=cord1 VALUE=Yes CHECKED>
<BR>
<INPUT TYPE= CHECKBOX NAME=cord2 VALUE=Yes CHECKED>
<BR>
<INPUT TYPE= CHECKBOX NAME=cord3 VALUE= CHECKED>
<BR>
</UL>
:

:
<TEXTAREA NAME=Resume ROWS=10 COLS=60>
5


</TEXTAREA>
:
<SELECT NAME=_ SIZE= MULTIPLE>
<SELECT NAME=>
<OPTION SELECTID Value=D1> 1
<OPTION SELECTID Value=D2> 2
<OPTION SELECTID Value=D3> 3
</SELECT>
1 Web ,
..

:
1.

2.

.
3.
.
4.

,
, .
5.

Web

.
Web ,
HTML , DHTML
6

( HTML) XML ( ).
Web ,
Web , , -,
. Web .
.7.6 Web .

URL

Web

HTML

HTML
HTTP
TCP/IP

.3. Web- Web-


.
:

, (PHP, Java

Script, JScript, VBScript)

Java

ActiveX

, ISAPI
7

IDC/HTX

ASP

CGI, Win CGI, API

HTML
Web .
Java Explore.
Java -
. Java - ,
C++. , ,
.
CGI .
, .
CGI .
: /++, Visual Basic, FoxPro, Perl,
PHP ..
ISAPI
ASP, PHP IDC/HTX ,
Web
, .
HTX HTML-,
HTML .
ASP HTML- SQL- . ASP Java Script,
.
PHP
, HTML

Web-, . ,
: ODBC, OLE DB, ADO.
ODBC .
8

OLE DB .
ADO ActiveX DataObject.

1.

2.

3.

4.

5.

?
6.

CHECKBOX.

7.

8.

, ,
?

9.

Web-.

14

(CSS, Cascade Style Sheets)
HTML. CSS , , , ,
. CSS ( , ),
, . CSS
. CSS
(, mestyle.css).
HTML- LINK.
:

Href - URL ,
9

Rel stylesheet; ,
,

Type text/css;
,

Media .


.
<head>
<Link href=mystyle.css rel=stylesheet type=text/css>
<Link href=mystyle_ex.css rel=stylesheet type=text/css>
</head>
HTML
(<style> </style>), HEAD .
CSS.
,
. :
.
{}.
[,] {: , : , }
:
H1.arial {color: red; font-family: arial}
H2,H3 {color: blue; font-family: newroman}
P { font-family: italic}

.
H1.arial {color: red; font-family: arial}
H2.newroman {color: blue; font-family: newroman}
P.italic (font-family: italic}
. bold {font-family: bold}
10

.
HTML
class.
.
<html>
<head>
<title> </title>
<! -- >
<style type=text/css>
h1.arial {color: red; font-family: arial}
h2.newroman {color: blue; font-family: newroman}
P.italic (font-family: italic}
. bold {font-family: bold}
</style>
</head>
<body>
<h1> </h1>
<p>
<h1 class=arial> </h1>
<h2> </h2>
<p class=italic>
<h2 class=arial> </h2>
<p class=bold>
</body>
</html>
style,
HTML , Class.
.
<html>
11

<body>
<h1> </h1>
<p>
<h1 style= color: red; font-family: arial>
</h1>
<h2> </h2>
<p style= font-family: italic >
--------------------------------</body>
</html>
.
CSS .
-1, : black, white,
red ..
RGB . 4
: ,
,
16- .
Color: rgb (255, 255, 0)
Color: rgb (100%, 100%, 0%)
Color: #FFFF00
Color: #FF0
.
<html>
<head>
<title> </title>
<style type=text/css>
Body (background-color: gray; font-size: 14pt; text-indent: 50pt)
h1 { background-color: white; color: blue}
h2.newroman {color: blue; font-family: newroman}
12

</style>
</head>
<body>
<h1> </h1>
<p>
</body>
</html>
.
(h1), (body),
.
.
.

Color
Background-

color
Font-family

Font size
Border-width
Border-style
Border-color

,
,

JavaScript
JavaScript , ,
HTML
.
HTML .
() .
, ,
.

HTML .

<script> </script>.
13

:
<html>
<head>
<title> JavaScript</title>
<script language= JavaScript >
<! JavaScript
//->
</script>
</head>
<body>
- - HTML JavaScript
</body>
</html>

Break

Continue

For

Function

If .. else

New

Return

Var

JavaScript : alert, write


1.
<script language= JavaScript >
Alert
</script>
2.
<script language= JavaScript >
Document.write
14

</script>
. .
For (i=0; i<=9; i++)
{
Document.write(i=+i+<br>);
}
. .
<html>
<head>
<title> JavaScript</title>
Function Test() {
Res=prompt( );
(Res==null)? Alert( Cancel}:
Alert ( :+Res);
}
</script>
</head>
<body>
Test()
</body>
</html>

1. ?
2.

CSS.

3. .
4. .
5. ?
6.

JavaScript?

7.

, JavaScript.
15

8.

JavaScript.

9. .
15
PHP MySQL
PHP (Personal Home Page)
. Web-,
.
, Web,
.
, ,
:
.
PHP:
- HTML-,
- ,
- Web-.
PHP
: dBASE, Informix, MS SQL Server, MySQL, Ingres,
Sybase .
PHP ODBC.
, PHP, , HTML.
.
<html>
<head>
<title> PHP</title>
<! -- >
</head>
<body>
16

<h1>Hello in PHP</h1>
<?PHP
Print Hello, world!;
Phpinfo();
?>
</body>
</html>
,
, :
Dreamweaver MX

HomeSite

EditPlus
Emacs
HTML-Kit
PHPEdit
- $
$name
$name-;
$age=33;
$name1=$name2;

print echo.
$today=;
Print_r($today);
echo .
, $name=;
<p> , <?php echo $name?></p>

,
define
17

Define (_,);
Define (weather, );
Define(inter,33);
: and, as, break, case, class, const, continue, declare, default, die,
do, echo, else, empty, exit, for, foreach, function, global, if, include, list, new, or,
print, return, switch, use, var, while.
: integer, floating point, string, Boolean
: +, -, *, /, %
:
$var1=5;
$var2=7;
$total=$var1+$var2;
$i=$i+1; $i++ $i .
:
$X+=2;, $Y-=3;, $A*=2;, $B/=3;

If()
{

}
Elseif()
{

}
Else
{

}
switch
Switch ($_)
18

{
Case ;
;
Break;
Case ;
;
Break;
- ----Default;
;
Break;
}
. .
1. for
2. while
3. do .. while
.
For ($i=1; $i<=3; $i++)
{
Echo $i. , !<br>;
}

Include (_);
Include ($filename);

Function _()
{
;
19

Return:
)
die , .
, MySQL
Mysql_connect (host, user, password)
Or die ( );
,

If (!mysql_connect (host, user, password))
{
Echo \n;
Exit;
}
MySQL
MySQL .
.
MySQL .
.
Create database employee;

Use employee;
Create table employee
(
empl_id int not null auto_increment primary key,
Name varchar(20),
Job varchar(30),
Department_id int not null references department(depart_id)
)type=InnoDB;

20

auto_increment , ,
.
Type=InnoDB ,
InnoDB. .
InnoDB, MyISAM.
Depart_id ,
references.
, ,
.
, .
Create table employeeSkill
(
empl_id int not null references employee(empl_id),
skill varchar(15) not null
primary key (empl_id, skill)
)type=InnoDB;

Integer (int), float, numeric, double, char, varchar, text, blob, date, time, datetime,
year

drop database employee;


drop table departamens;
alter table employee;
truncate .
Truncate table employee;
DML
Insert
21

Delete
Update
Select

Load data infile

Load data infile employee_infile.txt


Into table employee;

1.

PHP

2.

PHP

3.

PHP

4.
5.
6.
7. MySQL
8.

PHP

9.

MySQL

16
Oracle Database
1.
,
. Oracle9i

22

Oracle,
.
: ,
.
, ,
Oracle9i .
Oracle9i
. .1
.

oracle

(SGA)

Oracle.


Oracle

.1. Oracle
Oracle9i
(instance) Oracle. ,
Oracle
(System Global Area, SGA)
(background processes) Oracle. SGA
Oracle. (background processes)

23


. :

Smon (system monitor )

Pmon (process monitor )

Dbwr (database write )

Lgwr (log write )

Ckpt (checkpoint )

.
. ,
.
Oracle
. ,
.
, ,
(System Global Area SGA)
(Program Global Area PGA).
SGA ,
.
PGA ,
, .
, .
2.
(tablespace) ,
. ,
. Oracle
System SYS (.2). ,
. System
, . ,
24

(, ). SYS
System .

.

.
1

Oracle
1-System
2-sys
.
2

User_constraints

.
n

tab

dual

.2. System Sys


:
- :
, , , , , Oracle,
- :
, , .
3. PL/SQL ORACLE
Oracle .
25

Oracle database

Oracle Application Server ( )

Internet Development Suite (


)

Data Warehousing and Business Development (


)

Oracle

E-business

Suite

)
PL/SQL Procedural Language/Structured Query Language
( / )
PL/SQL Oracle 1988.
PL/SQL , ADA C.
PL/SQL , ,
Web .
Oracle , ,

Oracle9i

Java Java (Java


Virtual Machine JVM), PL/SQL. Oracle
. PL/SQL
.

26

Oracle

SQL


PL/SQL


SQL


.3. PL/SQL

.8.3 PL/SQL
. Oracle,
.
. , Oracle
, PL/SQL SQL
.
PL/SQL
[DECLARE]
,
BEGIN
- SQL
- PL/SQL
[EXEPTION]

27

END;
/
PL/SQL .
,
. PL/SQL
.
.
: -- , /* --- */ .
.
,
PL/SQL: ; ; (.8.4).

[DECLARE]

FUNCTION
RETURN
IS

PROCEDURE
IS

BEGIN

BEGIN

[EXCEPTION]

BEGIN

[EXEPTION]

END;

RETURN
[EXPECTION]

END;

END;

.4.
. .

PL/SQL

. (subprograms) PL/SQL,
.
. .
,

.
28

PL/SQL.
Oracle JDeveloper 10g - .
:
-
;
- ;
- , PL/SQL (, ,
).
iSQL*Plus SQL*Plus, .

iSQL*Plus
Server

Client

Server
Database
Table

Application
Server

Client

.5. iSQL*Plus
PL/SQL:
-
-
-
-

LOB ( )

:
VARCHAR2, NUMBER, DATE, BOOLEAN
:
_

_ := ;

:
29

_ := ;

DECLARE
L_name VARCHAR2(30);
L_today DATE := sysdate;
L_counter NUMBER :=0;
L_average_amount NUMBER(12,2);
Flag BOOLEAN := FALSE;
%TYPE
.
,
.
.
Balance NUMBER(7,2);
Min_balance balance%TYPE:=1000;
PL/SQL ,
.
.
Empno NUMBER(6) := &empno;
DEFINE

DEFINE lname :=Urman


:

IF
30

CASE


IF THEN
IF x = 0 THEN
Y:=1;
END IF;
BEGIN
IF x>y THEN
Max := x;
ELSE
Max := y;
END IF;
END;
CASE
CASE
WHEN 1 THEN 1
WHEN 2 THEN 2
WHEN 3 THEN 3
ELSE 5
END;
:
: LOOP, FOR, WHILE
LOOP
LOOP
;
EXIT [WHEN ];
31

END LOOP;
EXIT
WHILE
WHILE LOOP
1;
2;
...
END LOOP;
FOR
FOR I IN m . . n
LOOP
1;
END LOOP
.
DECLARE
m NUMBER :=1;
n NUMBER := 100;
BEGIN
FOR I IN m . . n LOOP
...
END LOOP;
END;
SQL PL/SQL
SELECT
:
SELECT _
32

INTO {_ [, _] . . .| _}
FROM
[WHERE ];
.
sotrud (ns, name),
ns , name .
SET SERVEROUTPUT ON
DECLARE
fname VARCHAR2(25);
BEGIN
SELECT name INTO fname
FROM sort WHERE ns=126;
DBMS_OUTPUT.PUT_LINE( Name is: ||fname);
END;

1.

Oracle

2. Oracle
3. .
4. .
5.

SGA, PGA.

6.
7. .
8.

5 ORACLE.

9.

PL/SQL.

10.

PL/SQL.

11. .
12.

PL/SQL.

13. .
14.

PL/SQL.

15. .
33

17
Oracle
1. PL/SQL.
. .
, .

.
:
CREATE [OR REPLACE] PROCEDURE _
[(1 [_1] _1,
[(2 [_2] _2,

. . .)]

IS|AS
_;
:
Begin
_;
END;
CALL:
CALL <_>

:
CREATE [OR REPLACE] FUNCTION _
[(1 [_1] _1,
[(2 [_2] _2,

. . .)]

RETURN _
34

IS|AS
_;

.
Oracle .
, 24
Oracle .
DBMS_OUTPUT.PUT_LINE
DBMS_OUTPUT.PUT_LINE - Oracle
PL / SQL .
SET SERVEROUTPUT ON.
SET SERVEROUTPUT ON
DEFINE p_annual_sal = 60000
DECLARE
v_sal NUMBER(9,2) := &p_annual_sal;
BEGIN
v_sal := v_sal/12;
DBMS_OUTPUT.PUT_LINE ('The monthly salary is ' ||
TO_CHAR(v_sal));
END;
/
2. SQL PL/SQL:
2-1. :
SELECT Statements in PL/SQL
SELECT select_list
INTO {variable_name[, variable_name]...
| record_name}
FROM
table
[WHERE condition];

35

DECLARE
v_deptno
NUMBER(4);
v_location_id
NUMBER(4);
BEGIN
SELECT department_id, location_id
INTO
v_deptno, v_location_id
FROM
departments
WHERE department_name = 'Sales';
...
END;
/
2-2.
BEGIN
INSERT INTO employees
(employee_id, first_name, last_name, email,
hire_date, job_id, salary)
VALUES
(employees_seq.NEXTVAL, 'Ruth', 'Cores', 'RCORES',
sysdate, 'AD_ASST', 4000);
END;
/
2-3.
DECLARE
v_sal_increase employees.salary%TYPE := 800;
BEGIN
UPDATE employees
SET
salary = salary + v_sal_increase
WHERE job_id = 'ST_CLERK';
END;
/
2-4.
DECLARE
v_deptno employees.department_id%TYPE := 10;
BEGIN
DELETE FROM employees
WHERE
department_id = v_deptno;
36

END;
/
3. :
3-1. IF-THEN-ELSE
DECLARE
v_hire_date DATE := '12-Dec-1990';
v_five_years BOOLEAN;
BEGIN
...
IF MONTHS_BETWEEN(SYSDATE,v_hire_date)/12 > 5 THEN
v_five_years := TRUE;
ELSE
v_five_years := FALSE;
END IF;
...
IF-THEN-ELSIF
...
IF v_start > 100 THEN
v_start := .2 * v_start;
ELSIF v_start >= 50 THEN
v_start := .5 * v_start;
ELSE
v_start := .1 * v_start;
END IF;
...
3-2. CASE
CASE selector
WHEN expression1 THEN result1
WHEN expression2 THEN result2
...
WHEN expressionN THEN resultN
[ELSE resultN+1;]
END;
. (, ,
)
37

p_grade:
SET SERVEROUTPUT ON
DEFINE p_grade = a
DECLARE
v_grade CHAR(1) := UPPER('&p_grade');
v_appraisal VARCHAR2(20);
BEGIN
v_appraisal :=
CASE v_grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
ELSE 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE ('Grade: '|| v_grade || '
Appraisal ' || v_appraisal);
END;
/
3-3. : LOOP
pl/sql :
- Basic loop
- FOR loop
- WHILE loop
3-3-1. Basic Loops
LOOP
1;
2;
...
EXIT [WHEN ];
END LOOP;

DECLARE
v_country_id locations.country_id%TYPE := 'CA';
v_location_id locations.location_id%TYPE;
v_counter
NUMBER(2) := 1;
v_city
locations.city%TYPE := 'Montreal';
38

BEGIN
SELECT MAX(location_id) INTO v_location_id FROM locations
WHERE country_id = v_country_id;
LOOP
INSERT INTO locations(location_id, city, country_id)
VALUES((v_location_id + v_counter),v_city, v_country_id );
v_counter := v_counter + 1;
EXIT WHEN v_counter > 3;
END LOOP;
END;
/
3-3-2. WHILE Loops
WHILE condition LOOP
;
...
END LOOP;

DECLARE
v_country_id
locations.country_id%TYPE := 'CA';
v_location_id locations.location_id%TYPE;
v_city
locations.city%TYPE := 'Montreal';
v_counter
NUMBER := 1;
BEGIN
SELECT MAX(location_id) INTO v_location_id FROM locations
WHERE country_id = v_country_id;
WHILE v_counter <= 3 LOOP
INSERT INTO locations(location_id, city, country_id)
VALUES((v_location_id + v_counter), v_city, v_country_id );
v_counter := v_counter + 1;
END LOOP;
END;
/
3-3-3. FOR Loops
FOR counter IN [REVERSE]
lower_bound..upper_bound LOOP
;
...
39

END LOOP;

DECLARE
v_country_id locations.country_id%TYPE := 'CA';
v_location_id locations.location_id%TYPE;
v_city
locations.city%TYPE := 'Montreal';
BEGIN
SELECT MAX(location_id) INTO v_location_id
FROM locations
WHERE country_id = v_country_id;
FOR i IN 1..3 LOOP
INSERT INTO locations(location_id, city, country_id)
VALUES((v_location_id + i), v_city, v_country_id );
END LOOP;
END;
/
3-4. SQL Cursor
- PL/SQL .
- SQL ORACLE
, SQL.
- PL/SQL, ,
SQL .
:
1- ,
2- ( SQL).
, DML .
, .
select
SQL
1- SQL%ROWCOUNT ,
SQL
( )
2- SQL%FOUND , TRUE,
SQL .

40

3- SQL%NOTFOUND , TRUE,
SQL , - .
4- SQL%ISOPEN FALSE , PL / SQL
,
:
Declare
Cursor c1 is select employee_id, last_name from employees;

------

190
191
200
..
203

.
pl/sql SQL%ROWCOUNT.
-
VARIABLE _ VARCHAR2(30)
DECLARE
v_employee_id employees.employee_id%TYPE := 176;
BEGIN
DELETE FROM employees
WHERE
employee_id = v_employee_id;
:_:= (SQL%ROWCOUNT ||
' row deleted.');
END;
/
PRINT _
(Explicit Cursor)
Declare -- SQL .
Open .
Fetch .
Empty , Fetch
.
Close .
41

1-Declare
CURSOR _ IS
; -- select .
2-OPEN _;
3-FETCH _ INTO [variable1, variable2, ...];
4-EXIT WHEN _ %ROWCOUNT NOTFOUND;
5-CLOSE _;


(%ISOPEN - %NOTFOUND -%FOUND - %ROWCOUNT)
:
.
SET SERVEROUTPUT ON
DECLARE
v_empno
employees.employee_id%TYPE;
v_ename
employees.last_name%TYPE;
CURSOR emp_cursor IS
SELECT employee_id, last_name
FROM employees;
BEGIN
OPEN emp_cursor;
LOOP
FETCH emp_cursor INTO v_empno, v_ename;
EXIT WHEN emp_cursor%ROWCOUNT > 10 OR
emp_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE (TO_CHAR(v_empno)
||'
'|| v_ename);
END LOOP;
CLOSE emp_cursor;
END ;


42

CREATE [OR REPLACE] PROCEDURE procedure_name


[(
parameter1 [mode1] datatype1, -- mode in/out/in out
parameter2 [mode2] datatype2,
. . .)]
IS|AS
PL/SQL Block;
END;
1. ,
10%. .
CREATE OR REPLACE PROCEDURE raise_salary
(p_id IN employees.employee_id%TYPE)
IS
BEGIN
UPDATE employees
SET salary = salary * 1.10
WHERE employee_id = p_id;
END;
/
2
,
CREATE OR REPLACE PROCEDURE query_emp
(p_id
IN employees.employee_id%TYPE,
p_name OUT employees.last_name%TYPE,
p_salary OUT employees.salary%TYPE,
p_comm OUT employees.commission_pct%TYPE)
IS
BEGIN
SELECT last_name, salary, commission_pct
INTO p_name, p_salary, p_comm
FROM employees
WHERE employee_id = p_id;
END;
/
SQL
sql EXECUTE.
VARIABLE g_name
VARCHAR2(25)
VARIABLE g_sal NUMBER
43

VARIABLE g_comm

NUMBER

EXECUTE query_emp(171, :g_name, :g_sal, :g_comm)


PRINT g_name
3
CREATE OR REPLACE PROCEDURE format_phone
(p_phone_no IN OUT VARCHAR2)
IS
BEGIN
p_phone_no := '(' || SUBSTR(p_phone_no,1,3) ||
')' || SUBSTR(p_phone_no,4,3) ||
'-' || SUBSTR(p_phone_no,7);
END format_phone;
/

1- VARIABLE g_phone_no VARCHAR2(15)
BEGIN
:g_phone_no := '8006330575';
END;
/
PRINT g_phone_no
2- EXECUTE format_phone (:g_phone_no)
PRINT g_phone_no

,
.
CREATE OR REPLACE FUNCTION get_sal
(p_id IN employees.employee_id%TYPE)
RETURN NUMBER
IS
v_salary employees.salary%TYPE :=0;
BEGIN
SELECT salary
INTO v_salary
FROM employees
WHERE employee_id = p_id;
RETURN v_salary;
END get_sal;
/
44


VARIABLE g_salary NUMBER
EXECUTE :g_salary := get_sal(117)
PRINT g_salary
SQL
SQL
. ,
.
select.
CREATE OR REPLACE FUNCTION tax (p_value IN NUMBER)
RETURN NUMBER IS
BEGIN
RETURN (p_value * 0.08);
END tax;
/
SELECT employee_id, last_name, salary, tax(salary)
FROM employees
WHERE department_id = 100;
,
DROP PROCEDURE raise_salary;
DROP FUNCTION get_sal;

user_objects.
SELECT object_name, object_type
FROM user_objects
WHERE object_type in ('PROCEDURE', 'FUNCTION')ORDER BY object_name;
,
user_source :
SELECT text
FROM user_source
45

WHERE name = 'QUERY_EMPLOYEE'


ORDER BY line;

PL/SQL,
,
,
.
:
-
:
INSERT, UPDATE, DELETE
Trigger timing --
, ,
.
- : BEFORE (), AFTER()
- : INSTEAD OF ()
: On table, view
: Row or statement ( )
WHEN clause: Restricting condition
Trigger body ( ): PL/SQL

CREATE [OR REPLACE] TRIGGER trigger_name

1 [OR 2 OR 3 ]
ON table_name
trigger_body
. ,
.
CREATE OR REPLACE TRIGGER _
BEFORE INSERT ON employees
BEGIN
IF (TO_CHAR(SYSDATE,'DY') IN ('SAT','SUN')) OR
46

(TO_CHAR(SYSDATE,'HH24:MI')
NOT BETWEEN '08:00' AND '18:00')
THEN RAISE_APPLICATION_ERROR (-20500,'You may
insert into EMPLOYEES table only during business hours.');
END IF;
END;
/
. , SQL
employees .
CREATE OR REPLACE TRIGGER audit_emp_values
AFTER DELETE OR INSERT OR UPDATE ON employees
FOR EACH ROW
BEGIN
INSERT INTO audit_emp_table (user_name, timestamp,
id, old_last_name, new_last_name, old_title,
new_title, old_salary, new_salary)
VALUES (USER, SYSDATE, :OLD.employee_id,
:OLD.last_name, :NEW.last_name, :OLD.job_id,
:NEW.job_id, :OLD.salary, :NEW.salary );
END;
/
(:new)
,
(:old) ,
USER : ,
SYSDATE : .

16.

PL/SQL.

17. .
18. .
19. .
20. .
21. .
22.

SQL PL/SQL.

23. .
24. .
47

48

Оценить