Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PL/SQL ѧϰ±Ê¼Ç3

 SQL> var a number
SQL> begin
2 :a :=1000;
3 end;
4 /
PL/SQL procedure successfully completed.
SQL> edit
Wrote file afiedt.buf
1 begin
2 dbms_output.put_line(:a);
3* end;
SQL> /
ͨ¹ýÕâ¸ö´úÂë¿ÉÒÔ¿´³öͨ¹ýpl/sql³õʼ»¯¸³ÖµµÄBind variable¿ÉÒÔ±»ÆäËûPl/sql³ÌÐòµ÷ÓÃ
%type ÀàÐÍÓ¦Óõϰ Èç¹ûÇ°ÃæÓõÄÊÇdatabase columnµÄ»° ÄÇô²»¿ÉÒÔ¼Ónot null,Ç°ÃæÒýÓõÄÊÇÉùÃ÷µÄ±äÁ¿¿ÉÒÔÓ¦ÓÃnot null
A NOT NULLdatabase column constraint does not apply to variables that are declared using %TYPE.  
Therefore, if you declare a variable using the %TYPEattribute that uses a database column defined as NOT  
NULL, you can assign the NULLvalue to the variable.  
eg:
°ó¶¨±äÁ¿
A bind variable is a variable that you declare in a host environment.
 Bind variables can be used to pass run-time values, either number or character, into or out of one or more PL/SQL programs. The PL/SQL  
programs use bind variables as they would use any other variable. You can reference variables declared in the  
host or calling environment in PL/SQL statements, unless the statement is in a procedure, function, or  
package. This includes host language variables declared in precompiler programs, screen fields in Oracle   Developer Forms applications, and iSQL*Plus bind variables.
°ó¶¨±äÁ¿¿ÉÒÔÔÚÖ÷»ú»·¾³ÏÂÉùÃ÷ ¿ÉÒÔÔÚsqlplus ÕâÖÖÓ¦ÓóÌÐòÏÂÉùÃ÷ È»ºópl/sql³ÌÐòÀ´µ÷Óà µ÷ÓÃÐèÒªÔڸñäÁ¿Ç°¼Ócolon
¸³ÖµµÄʱºò¿ÉÒÔʹÓà exec :var_name := 10000; or begin :var_name := 1000 end; »òÕßÊÇÔÚPL/SQLÖи³Öµ
print(sqlplus command)¿ÉÒÔ´òÓ¡³öÕâ¸öÖµ
SQL> var result number
SQL> begin
2 select (sal*12) + nvl(comm,0)
3 into :result
4 from emp
5 where empno = 7369;
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> print result
RESULT
------
9600
SQL> exec :result = 10000
BEGIN :result = 10000; END;
*
ERROR at line 1:
ORA-06550: line 1, column 15:
PLS


Ïà¹ØÎĵµ£º

SQL²éѯЧÂÊ 100wÊý¾Ý²éѯֻҪ1Ãë

»úÆ÷Çé¿ö
p4: 2.4
ÄÚ´æ: 1 G
os: windows 2003
Êý¾Ý¿â: ms sql server 2000
Ä¿µÄ: ²éѯÐÔÄܲâÊÔ,±È½ÏÁ½ÖÖ²éѯµÄÐÔÄÜ
SQL²éѯЧÂÊ step by step
-- setp 1.
-- ½¨±í
create table t_userinfo
(
userid int identity(1,1) primary key nonclustered,
nick&nbs ......

×¢Èë³£ÓÃSQLÓï¾ä


and exists (select * from sysobjects) //ÅжÏÊÇ·ñÊÇMSSQL
and exists(select * from tableName) //ÅжÏij±íÊÇ·ñ´æÔÚ..tableNameΪ±íÃû
and 1=(select @@VERSION) //MSSQL°æ±¾
And 1=(select db_name()) //µ±Ç°Êý¾Ý¿âÃû
and 1=(select @@servername) //±¾µØ·þÎñÃû
and 1=(select IS_SRVROLEMEMBER('sysadmin')) //Å ......

SQL code¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨

SQL code¶¯Ì¬sqlÓï¾ä»ù±¾Óï·¨
 1 :ÆÕͨSQLÓï¾ä¿ÉÒÔÓÃExecÖ´ÐÐ
eg: Select * from tableName
Exec('select * from tableName')
Exec sp_executesql N 'select * from tableName'
 -- Çë×¢Òâ×Ö·û´®Ç°Ò»¶¨Òª¼ÓN
2:×Ö¶ÎÃû£¬±íÃû£¬Êý¾Ý¿âÃûÖ®Àà×÷Ϊ±äÁ¿Ê±£¬±ØÐëÓö¯Ì¬SQL
eg: declare @fname varchar(20) ......

sql·ÖÒ³

declare @p int
declare @p1 int
declare @count int
set @p=0
set @p1=10
set @count=2
if(@count<>0 or @count<>1)
set @p=@p1*@count-10
SELECT [t1].[userid], [t1].[username], [t1].[userorder]
from (
    SELECT ROW_NUMBER() OVER (ORDER BY [t0].[userorder]) AS [ROW_NU ......

sql ²éѯ

ÓÐÒÔ϶þÕÅ±í£º
Õþµ³±í£ºÕþµ³ID£¬Õþµ³Ãû³Æ
ÒéÔ±±í£ºÒéÔ±ID£¬ÒéÔ±Ãû³Æ£¬Õþµ³ID
ÒªÇó²éѯËùÓеÄÕþµ³ÐÅÏ¢£¬°üº¬£ºÕþµ³Ãû³Æ£¬ÒéÔ±ÈËÊý£¬²¢°´ÒéÔ±ÈËÊýµÄ½µÐòÅÅÁУ¨²»¿ÉÒÔÓÃ×Ó²éѯ£©¡£
Õý½â:
SELECT a.name,
  COUNT(b.id) AS counts
  from zhen a
left join
  yi b
on a.id=b.zhenid
GROUP ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ