存储过程创建语法:
create or replace procedure 存储过程名(param1 in type,param2 out type)
as
变量1 类型(值范围);
变量2 类型(值范围);
Begin
Select count(*) into 变量1 from 表A where列名=param1;
If (判断条件) then
Select 列名 into 变量2 from 表A where列名=param1;
Dbms_output。Put_line(‘打印信息’);
Elsif (判断条件) then
Dbms_output。Put_line(‘打印信息’);
Else
Raise 异常名(NO_DATA_FOUND);
End if;
Exception
When others then
Rollback;
End;
注意事项:
1, 存储过程参数不带取值范围,in表示传入,out表示输出
2, 变量带取值范围,后面接分号
3, 在判断语句前最好先用count(*)函数判断是否存在该条操作记录
4, 用 ......
1. ASCII
返回与指定的字符对应的十进制数;
SQL> select ascii(A) A,ascii(a) a,ascii(0) zero,ascii( ) space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
2. CHR
给出整数,返回对应的字符;
SQL> select chr(54740) zhao,chr(65) chr65 from dual;
ZH C
-- -
赵 A
3. CONCAT
连接两个字符串;
SQL> select concat(010-,88888888)||转23 高乾竞电话 from dual;
高乾竞电话
----------------
010-88888888转23
4. INITCAP
返回字符串并将字符串的第一个字母变为大写;
SQL> select initcap(smith) upp from dual;
UPP
-----
Smith
5.INSTR(C1,C2,I,J)
在一个字符串中搜索指定的字符,返回发现指定的字符的位置;
C1 被搜索的字符串
C2 希望搜索的字符串
I 搜索的开始位置,默认为1
J 出现的位置,默认为1
SQL> select instr(oracle traning,ra,1,2) instring from dual;
INSTRING
---------
9
6.LENGTH
返回字符串的长度;
SQL> select name,length(name),addr,length(addr),sal,length(to_char(sal)) from gao.nchar_tst;
NAME LENGTH(NAME) ADDR ......
单表数据迁移:支持clob,blob
exp estarcom/estarcom@ORACLE tables=AA direct=y file=C:/AAA1.dmp
imp estarcom/estarcom@ORACLE tables=AA file=C:/AAA1.dmp fromuser=estarcom touser=estarcom
全库数据迁移
exp userid=zhongxin/zhongxin@ORACLE owner=zhongxin file=d:/zhongxin_200811111946.dmp log=d:/zhongxin_200811111946.log
imp zhongxin/zhongxin@oracle file=d:/mianyang_20081119.dmp fromuser=mianyang touser=zhongxin
EXP/IMP用法
exp/imp适合于同类型数据库之间数据转换
共有四种不同模式:表,用户,表空间,数据库
现分别举例说明
1.表级别
$ exp hr/hr tables=jobs direct=y file=/data/table_jobs.dmp
$ imp hr/hr tables=jobs direct=y file=/data/table_jobs.dmp
2.用户级别
$ exp "'sys/sys as sysdba'" owner=hr direct=y file=/data/owner_hr.dmp
$ imp "'sys/sys as sysdba'" fromuser=hr touser=hr file=/data/owner_hr.dmp
3.表空间级别
$ exp "'sys/sys as sysdba'" transport_tablespace=y direct=y tablespaces=examples file=/data/ts_exa ......
ADF是(Application Development Framework)的简称,它的前身是BC4J。 光听这个名字就知道它是一个end-to-end的框架。和Spring一样它在企业应用架构的每一个层次都提供了它的支持。ADF的架构如下图所示:
在每一层ADF都有它的一些组件。我这次主要想讲讲ADF的data binding,因为它隔离了业务逻辑层和web层,使得两个层次的独立性更强。但是,ADF似乎做得过于复杂,使得很难上手使用。
ADF中关键的数据绑定概念如下:
Data Control:
Data Control是对业务接口的抽象,也就是说所有访问业务对象的方法现在都通过Data Control来进行,这样使得绑定层使用一种方式来访问数据,不论后台的数据对象是种实现。可以把Data Control看做是一种代理机制。
Iterator Bindings and Control Bindings:
Binding 是一种轻量级的对象,它的主要目的就是让后台数据和前台显示解藕,这是老生常谈的问题,让我们看看ADF是怎么做的。Iterator Binding 和提供集合对象数据的Data Control合作。 Control Bindings 则提供了一个标准的接口让用户界面可处理集合对象或者调用业务方法。
Binding Containers:
Binding Container 对象记录了某一个用户界面使用了哪些iterator binding、c ......
http://www.diybl.com/course/3_program/java/javajs/2008429/111906.html
如果要使用池的话,就必须使用OracleConnectionCacheImpl,共有三种池的策略:
DYNAMIC_SCHEME(是动态增加.用完如果超过上限则关掉)
The cache will create connections above the specified maximum limit
when necessary but will in turn close connections as they are
returned to the cache until the number of connections is within the
maximum limit. Connections will never be cached above the maximum
limit. This is the default setting.
FIXED_RETURN_NULL_SCHEME (直接返回Null)
The cache will return a null connection once the maximum connection limit has been exceeded.
FIXED_WAIT_SCHEME (始终等待)
The cache will wait until there is a connection available and will then return it to the calling application.
oracle.jdbc.pool
Class OracleConnectionCacheImpl
http://download.oracle.com/otn/utilities_drivers/jdbc/101020/javadoc/index.html
oracle J ......
The RETURNING INTO clause allows us to return column values for rows affected by DML statements. The following test table is used to demonstrate this clause.
DROP TABLE t1;
DROP SEQUENCE t1_seq;
CREATE TABLE t1 (
id NUMBER(10),
description VARCHAR2(50),
CONSTRAINT t1_pk PRIMARY KEY (id)
);
CREATE SEQUENCE t1_seq;
INSERT INTO t1 VALUES (t1_seq.nextval, 'ONE');
INSERT INTO t1 VALUES (t1_seq.nextval, 'TWO');
INSERT INTO t1 VALUES (t1_seq.nextval, 'THREE');
COMMIT;
When we insert data using a sequence to generate our primary key value, we can return the primary key value as follows.
SET SERVEROUTPUT ON
DECLARE
l_id t1.id%TYPE;
BEGIN
INSERT INTO t1 VALUES (t1_seq.nextval, 'FOUR')
RETURNING id INTO l_id;
COMMIT;
DBMS_OUTPUT.put_line('ID=' || l_id);
END;
/
ID=4
PL/SQL procedure successfully completed.
SQL>
The syntax is also available for update and delete statements.
SET SERVEROUTPUT ON
DECLARE
l_id t1.id%TYPE;
BEGIN
UPDATE t1
SET ......