易截截图软件、单文件、免安装、纯绿色、仅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 ......

【改斜归正】 sqlserver sql 分页语句

      在Google上使用“sql 分页”关键字进行搜索,几乎所有的答案都是那三条。其二效率最高,其三使用游标,效率最差。
      下面是那三种方法 (插入代码没有sql选项)
方法1:
适用于 SQL Server 2000/2005
SELECT TOP 页大小 *
from table1
WHERE ......

PL/SQL 学习笔记1

PL/SQL 不具备输入输出的能力
但是可以依靠环境来执行数值的输入输出给PL/SQL 块
SQLPLUS 环境用substitution variables 和 host(bind) variable 来传入数值给PL/SQL块
substitution variable: such as a preceding ampersand  &a
host(bind) variable : such as a  preceding colon :x
替 ......

SQL SERVER 游标

SqlServer 2000 游标用法小例 翻弹押尾桑Cannon(卡侬) »
--------------------------------------------------------------------------------
DECLARE CURSOR (T-SQL)创建游标
September 14th, 2006 by OoperMan  (1 votes, average: 5 out of 5) Loading ...
SQL Server 2005 联机丛书
DECLARE CURSOR ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号