PL/SQLÀý×Ó2
create or replace procedure c
(
v_deptno in emp.deptno%type,
v_max out emp.sal%type
)
as
begin
select max(sal+nvl(comm,0)) into v_max from emp where deptno=v_deptno;
end;
create or replace procedure cc
(
v_empno in emp.empno%type,
v_sal out emp.sal%type,
v_comm out emp.comm%type,
v_tol out emp.sal%type
)
as
begin
select sal,nvl(comm,0),(sal+nvl(comm,0)) into v_sal,v_comm,v_tol from emp where
empno=v_empno;
end;
create or replace procedure upsal
(
v_deptno in number,
v_sal in number
)
as
begin
update emp set sal=v_sal where deptno=v_deptno;
end;
create or replace procedure somsal
(
v_empno in number,
v_sal in number
)
as
begin
update emp set sal=v_sal where empno=v_empno;
end;
create or replace function maxsal
(
v_deptno in number
)
return number
is
v_maxsal number;
begin
select max(sal) into v_maxsal from emp where deptno=v_deptno;
return v_maxsal;
end;
create or replace procedure cursor
(v_cursor out mypack.mycursor
)
is
begin
open v_cursor for select * from emp ;
end ;
create or replace function selalldep
(a out number,
c in number
)
return number
as
b number;
begin
select count(empno),sum(sal+nvl(comm,0)) into a,b from emp
where deptno=c;
return b;
end;
create or replace package mypack is
type mycursor is ref cursor;
end ;
declare
i number(3):=1;
j number(3):=2;
begin
loop
insert into t_user values(i,'a'||i,'a'||i,1,to_date('2007-01-01','yyyy-mm-dd'),1,i,'sdd');
insert into t_user values(j,'a'||j,'a'||j,1,to_date('2007-01-01','yyyy-mm-dd'),2,j,'sdd');
i:=i+2;
j:=j+2;
exit when i>600 and j>600;
end loop;
end;
Ïà¹ØÎĵµ£º
sqlºËÐÄÓï¾ä(·Ç³£ÊµÓõö¼¼ÇÉ)²åÈëÊý¾Ý
Ïò±íÖÐÌí¼ÓÒ»¸öмǼ£¬ÄãҪʹÓà sql INSERT Óï¾ä¡£ÕâÀïÓÐÒ»¸öÈçºÎʹÓÃÕâÖÖÓï¾äµÄÀý×Ó£º
INSERT mytable (mycolumn ......
2009-12-08 18:53
sql½Å±¾Êǰüº¬Ò»µ½¶à¸ösqlÃüÁîµÄsqlÓï¾ä£¬ÎÒÃÇ¿ÉÒÔ½«ÕâЩsql½Å±¾·ÅÔÚÒ»¸öÎı¾ÎļþÖУ¨ÎÒÃdzÆÖ®Îª“sql½Å±¾Îļþ”£©£¬È»ºóͨ¹ýÏà¹ØµÄÃüÁîÖ´ÐÐÕâ¸ösql½Å±¾Îļþ¡£»ù±¾²½ÖèÈçÏ£º
1¡¢´´½¨°üº¬sqlÃüÁîµÄsql½Å±¾Îļþ
ÎļþÖаüº¬Ò»Ð©ÁеÄsqlÓï¾ä£¬Ã¿ÌõÓï¾ä×îºóÒÔ;½á⣬ÎļþÄÚÈÝʾÀýÈçÏ£º
--´´½ ......
SQLÀïµÄEXISTSÓëin¡¢not existsÓënot in
ϵͳҪÇó½øÐÐSQLÓÅ»¯£¬¶ÔЧÂʱȽϵ͵ÄSQL½øÐÐÓÅ»¯£¬Ê¹ÆäÔËÐÐЧÂʸü¸ß£¬ÆäÖÐÒªÇó¶ÔSQLÖеIJ¿·Öin/not inÐÞ¸ÄΪexists/not exists
Ð޸ķ½·¨ÈçÏ£º
inµÄSQLÓï¾ä
SELECT id, category_id, htmlfile, title, convert(varchar(20),begintime,112) as pubtime
from tab_oa_pub WHERE ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE da ......