PL/SQL³õѧÕ߱ضÁ£º¼¸Ê®¸öʵÓõÄPL/SQL
µÚÒ»½×¶Î
Q.±àдһ¸öPL/SQL³ÌÐò¿éÒÔÏÔʾËù¸ø³ö¹ÍÔ±±àºÅµÄ¹ÍÔ±µÄÏêϸÐÅÏ¢¡£
A.
DECLARE
erec emp%ROWTYPE;
BEGIN
SELECT * INTO erec from emp WHERE empno=&¹ÍÔ±±àºÅ;
DBMS_OUTPUT.PUT_LINE('EmpNo' || ' ' || 'Ename' || ' '|| 'Job' || ' ' || 'Manager' || ' ' || 'HireDate' || ' ' || 'Salary' || ' ' || 'Commision' || ' ' || 'DeptNo');
DBMS_OUTPUT.PUT_LINE(erec.ename || ' ' || erec.job || ' ' || erec.mgr || ' ' ||erec.hiredate || ' ' || erec.sal || ' ' || erec.comm || ' ' || erec.deptno);
END;
/
Q.±àдһ¸öPL/SQL³ÌÐò¿éÒÔ¼ÆËãij¸ö¹ÍÔ±µÄÄê¶Èнˮ×ܶ
A.
DECLARE
esal NUMBER;
eename emp.ename%TYPE;
BEGIN
SELECT (NVL(sal,0)+NVL(comm,0))*12,ename INTO esal,eename from emp WHERE empno=&¹ÍÔ±±àºÅ;
DBMS_OUTPUT.PUT_LINE(eename || '''s Years Salary is ' || esal);
END;
/
Q.°´ÏÂÁмÓн±ÈÖ´ÐУº
Deptno Raise(%age)
10 5%
20 10%
30 15%
40 20%
¼ÓнµÄ°Ù·Ö±ÈÊÇÒÔËûÃÇÏÖÓеÄнˮΪ¸ù¾ÝµÄ¡£Ð´Ò»PL/SQLÒÔ¶ÔÖ¸¶¨¹ÍÔ±¼Óн¡£
A.
DECLARE
vcounter NUMBER:=10;
vraise NUMBER;
BEGIN
LOOP
EXIT WHEN vcounter>40;
UPDATE emp set sal=NVL(sal,0)+NVL(sal,0)*0.05 WHERE deptno=vcounter;
vcounter:=vcounter+10;
END LOOP;
END;
/
Q.±àдһPL/SQLÒÔÏò"emp"±íÌí¼Ó10¸öйÍÔ±±àºÅ¡£
£¨Ìáʾ£ºÈç¹ûµ±Ç°×î´óµÄ¹ÍÔ±±àºÅΪ7900£¬ÔòйÍÔ±±àºÅ½«Îª7901µ½7910£©
A.
DECLARE
vcounter NUMBER;
BEGIN
SELECT MAX(empno) INTO vcounter from emp;
FOR i IN 1..10
LOOP
vcounter:=vcounter+1;
INSERT INTO emp(empno) VALUES(vcounter);
END LOOP;
END;
/
Q.ֻʹÓÃÒ»¸ö±äÁ¿À´½â¾öʵÑé¿Î×÷Òµ4¡£
A
DECLARE
erec emp%ROWTYPE;
-- vraise NUMBER;
BEGIN
SELECT * INTO erec
from emp
WHERE ename='&ename';
IF erec.job='CLERK' THEN
UPDATE emp SET sal=sal+500 WHERE empno=erec.empno;
ELSIF erec.job='SALESMAN' THEN
UPDATE emp SET sal=sal+1000 WHERE empno=erec.empno;
ELSIF e
Ïà¹ØÎĵµ£º
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--ÿҳÏÔʾ¼Ç¼ÌõÊý
@currentpage int output,--µÚ¼¸Ò³
@orderid nvarchar(50),--Ö÷¼üÅÅÐò
@sort int,--ÅÅÐò·½Ê½£¬1±íʾÉýÐò£¬0±íʾ½µÐòÅÅÁÐ
......
ÈÕÖ¾ÎļþÂú¶øÔì³ÉSQLÊý¾Ý¿âÎÞ·¨Ð´ÈëÎļþʱ£¬¿ÉÓÃÁ½ÖÖ·½·¨£º
¡¡¡¡Ò»ÖÖ·½·¨£ºÇå¿ÕÈÕÖ¾¡£
¡¡¡¡1£®´ò¿ª²éѯ·ÖÎöÆ÷£¬ÊäÈëÃüÁî
¡¡¡¡DUMP TRANSACTION Êý¾Ý¿âÃû WITH NO_LOG
¡¡¡¡2.ÔÙ´ò¿ªÆóÒµ¹ÜÀíÆ÷--ÓÒ¼üÄãҪѹËõµÄÊý¾Ý¿â--ËùÓÐÈÎÎñ--ÊÕËõÊý¾Ý¿â--ÊÕËõÎļþ--Ñ¡ÔñÈÕÖ¾Îļþ--ÔÚÊÕËõ·½Ê½ÀïÑ¡ÔñÊÕËõÖÁXXM,ÕâÀï»á¸ø³öÒ»¸öÔÊÐíÊÕËõµ ......
DATEDIFF
·µ»Ø¿çÁ½¸öÖ¸¶¨ÈÕÆÚµÄÈÕÆÚºÍʱ¼ä±ß½çÊý¡£
Ò»¡¢ Óï·¨
DATEDIFF ( datepart , startdate , enddate )
¶þ¡¢²ÎÊý
datepar ......
×÷Õß
£º
Takayuki Hoshino
׫¸åÈË
£º
Juergen Thomas
¼¼
Êõ
ÉóÔÄÈË
£º
Sanjay Mishra
SQL Server Ϊ SAP Ó¦ÓóÌÐòÌṩÁË׿ԽµÄÊý¾Ý¿âƽ̨¡£ÏÂÁн¨Òé¸ÅÊöÁËÕë¶Ô SAP ʵÏÖά»¤ SQL Server Êý¾Ý¿âµÄ×î¼Ñ×ö·¨¡£
ÿÌìÖ´ÐÐÍêÕûÊý¾Ý¿â±¸·Ý
´Ó
¼¼Êõ½Ç¶ÈÀ´Ëµ£¬Áª»ú±¸·Ý SAP Êý¾Ý¿â²»³ÉÎÊÌâ¡£ÕâÒâζ×Å£¬×îÖ ......
ÕªÒª£º±¾ÎĽéÉÜÁËÔÚ¿Í»§»úÉÏ´¦Àí Microsoft sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) ²éѯµÄ·½Ê½£¬¸÷ÖÖ¿Í»§»úÓë sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) µÄ½»»¥·½Ê½£¬ÒÔ¼° sql server(WINDOWSƽ̨ÉÏÇ¿´óµÄÊý¾Ý¿âƽ̨) ÔÚ´¦Àí¿Í»§»ú³ÌÐòµÄÇëÇóʱÐèÒªÍê³ÉµÄ¹¤×÷¡£
¼ò½é
¡¡¡¡Microsoft(R) sql server(WINDOWSƽ̨ÉÏÇ¿ ......