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
相关文档:
在数据库应用程序发布时,客户端安装在局域网中的主机A上,sql server 安装在该局域网的主机B上。客户端软件中包含有它要连接的数据库的信息。如数据源,服务器名称,数据库等,实例:data source=SQLOLEDB;SERVER=DongZi\sqlExpress;uid=sa;pwd=123;database=MachineRoom
。那么我们在主� ......
在.Net Framework 3.5 中,最激动人心的就是增加了LINQ功能,LINQ在数据集成的基础上提供了新的轻型方式。有了LINQ,我们创建的查询现在就编程了.Net 框架的一个成员,在对要操作的数据存储执行查询时,会很快发现他们现在的操作方式类似于系统中的类型。这说明,现在可以使用任意兼容.Net 的语言来查询底层的数据存储,� ......
如下列出查询表达式,常用操作符,与SQL语句对应。
where 关键字的使用
public void MyWhere()
{
NorthwindDataContext dc = new NorthwindDataContext();
//查询产品名称以L开头的记录
var query = from p in dc.Products
where p.Prod ......
SQL操作全集
下列语句部分是Mssql语句,不可以在access中使用。
SQL分类:
DDL—数据定义语言(CREATE,ALTER,DROP,DECLARE)
DML—数据操纵语言(SELECT,DELETE,UPDATE,INSERT)
DCL—数据控制语言(GRANT,REVOKE,COMMIT,ROLLBACK)
首先,简要介绍基础语句:
1、说明:创建数据库
CREATE ......
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)
......