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语句对应。
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、说明:创建数据库
CREA ......
private void button2_Click(object sender, EventArgs e)//增
{
try
{
Customers ct = new Customers();
ct.CustomerID = "test";
ct.CompanyName = "test";
NorthwindDataContext nc = new NorthwindDataContex ......
1、在另一台机器上建立独立的数据库服务器,作为链接目标
2、本地数据库服务器上添加“链接服务器”:
名字:随便取一个名字
服务器类型:选择数据源:Microsoft OLE DB Provider for SQL Server
数据源:写别名(在客户端网络实用工具中设置)
选中RPC和RPC输出 ......
有以下二张表:
政党表:政党ID,政党名称
议员表:议员ID,议员名称,政党ID
要求查询所有的政党信息,包含:政党名称,议员人数,并按议员人数的降序排列(不可以用子查询)。
正解:
SELECT a.name,
COUNT(b.id) AS counts
from zhen a
left join
yi b
on a.id=b.zhenid
GROUP ......