PL/SQL语言简介
一、 PL/SQL语言简介
(本讲义之所有程序均调式通过)
首先我们看一个简单之例子,下面这个例子是统计从1至100的总和.
declare
i number:=0; /*声明变量井给初值*/
t number:=1;
error_message exception; /*声明一个出错处理*/
begin
for t in 1..100 loop
i:=i+t;
end loop;
if i>=5050 then
raise error_message; /*引发错误处理*/
else
insert into c_nt(c_t) values(i);
end if;
exception
when error_message then
insert into c_nt(c_t) values(0);
end;
² 从上例中可以看出PL/SQL语法的一般规则.
PL/SQL中语句以分号(;)结尾.
开始程序块的PL/SQL语句(如IF…或BEGIN语句)没有分句.
文本值括在单引号(‘ ‘)内,而不是(“ “).
过程只允许最后有一个出口..
² PL/SQL程序可以分为三个部分
DECLARE部分用于变量、常量、函数、过程、Cursor.
BEGIN部分包含PL/SQL块中要执行的代码 用于程序处理,其中可以调用函数、过程.
Exception 部分用于出错处理.
下面我们再看一个例子:
declare
i number :=1;
t number :=1;
p number :=1;
/*create table c_ny(c_t number,cou_t number);*/
function aa(xx number)return number is /* define function*/
tt number;
ct number:=1;
j number:=1;
begin
while
相关文档:
INSERT INTO
tableName ( columnName1, columnName2, columnName3, columnName4)
VALUES ( '45', '西藏办', TO_Date( '2010-03-10 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), NULL,);
commit; ......
select ks.login_name,ks.exam_name,ks.start_time,ks.end_time,cj.score
from (
select u.user_id,u.login_name,e.* from cphrms.EXAM_USER eu, cphrms.users u, cphrms.exam_info e
where eu.user_id = u.user_id and eu.exam_id = e.exam_id
) ks
left ......
Student(S#,Sname,Sage,Ssex) 学生表
Course(C#,Cname,T#) 课程表
SC(S#,C#,score) 成绩表
Teacher(T#,Tname) 教师表
问题:
1、查询“001”课程比“002”课程成绩高的所有学生的学号;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,score
fr ......
1.什么叫SQL注入?如何防止?请举例说明
答:SQL注入是常见的利用程序漏洞进行攻击的方法。导致sql注入攻击并非系统造成的,主要是程序中忽略了安全因素,利用sql语言漏洞获得合法身份登陆系统
例如:
"Select * from users where name='"+uName+"' and pwd='"+uPwd+"' " ......
常用: Select CONVERT(varchar(100), GETDATE(), 8): 10:57:46
Select CONVERT(varchar(100), GETDATE(), 24): 10:57:47
Select CONVERT(varchar(100), GETDATE(), 108): 10:57:49
Select CONVERT(varchar(100), GETDATE(), 12): 060516 Select CONVERT(varchar(100), GETDATE(), 23): 2006-05-16 ......