`
danielhjd
  • 浏览: 243277 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论
文章列表
第一:调用函数的例子: package daniel.test; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Types; public class ConnectionPro { /**建立数据库的连接 * @param args */ public static Connection getConnection(){ ...
 定义:instead of       1) 基于view表单的处理可以在表和视图上指定一个instead of 触发器       2) 执行这种触发器可以代替原来的触发器,instead of 触发器扩展了视图跟新类型       3) 每一个表和视图只能有一个instead of 触发器       4) INSTEAD OF触发器被用于更新那些没有办法通过正常方式更新的视图       5) INSTEAD OF触发器的主要优点就是可以使不能更新的视图支持更新。基于多个表的视图必须使用。       6) INSTEAD OF触发器来支持多个表中数据的插入、更新和删除操作 ...
第一:触发器(trigger) 触发器(trigger)是指隐含执行的存储过程procedure,当定义触发器时必须要指定触发事件和触发的操作,通常触发事件包括insert,update,delete语句,触发器实际上就是一个pl/sql(procedure language/Structured Query Language).create trigger来创建触发器;   第二:触发器的作用; a.允许/限制对表的修改 b.自动派生列,如自增字段 c.强制数据的一致性 d.提供审计和日志记录 e.防止无效的事务处理 f.启动复杂的业务逻辑   第三:触发器的语法; ...
第一:loop... exit when...end loop; declare temp_salary employee.salary%type; temp_emp employee%rowtype; cursor mycursor is select * from employee where employee.salary>temp_salary; begin temp_salary:=2000; open mycursor; loop fetch mycursor into temp_emp; exit when mycursor%notfound; d ...
创建一个带参数的procedure temp_pr(): create or replace procedure temp_pr(temp_no in employee.empid%type,temp_name out employee.empname%type)as begin select employee.empname into temp_name from employee where employee.empid=temp_no; end; 在上一篇关于procedure的日志中提到 as 在这里的功能相当于 declare的作用 用来声明变量,此处没有变量所以as后面接代 ...
Gramma:   1:声明一个exceptin:  declare  exception_name exception;   2:触发一个exception;  raise exception_name;   3:捕获一个exception when exception_name1 then statements; when exception_name2 then statements   代码: declare a exception; t_salary employee.salary%type; begin select salary into t_s ...
 1:定义procedure(在高级程序设计语言中的模块的概念) create or replace procedure procedure_name (param_1 in type,param_2 in out type) as param_inner type begin statement; end;   a:不含参数的procedure create or replace procedure temp as temp_salary employee.salar ...
Defined cursor ; cursor mycursor is select * from employees where employees.salary>tempsal;   Learning point on cursor; declare tempsal employees.salary%type; cursor mycursor is select * from employees where employees.salary>tempsal; currecord employees%rowtype; ...
Definition: cursor的作用是从数据表中提取来的数据,以临时表的形式存放在内存中,在cursor有一个数据指针,在initical status下指向首记录,利用fetch语句可以移动指针,从而对cursor的数据进行各种操作,然后将操作结果写回表中;   Gramma/parse: 注意:cursor是一种数据类型 cursor name is select satements   open mycursor; 打开游标的过程有以下两个步骤: (1)将符合条件的记录送入内存. (2)将指针指向第一条记录.   fetch mycursor into  ...
语法:   savepoint 保存点的名称; rollback to 保存点的名称;   --savepoint-- insert into users values(user_seq.nextval,'anan','anan','an','1'); savepoint a; insert into users values(user_seq.nextval,'demon','demon','dem','1'); insert into users values(user_seq.nextval,'kevin','kevin','kev','1'); --rollback ...
(1)数值表达式--+(加法),-(减法),*(乘法),/(除法)和**(乘方)等-- declare --此处number(9)和integer都行-- result_1 integer; begin result_1:=10+3*4-20+5**2; dbms_output.put_line('输出的结果为='||to_char(result_1)); end;  --dbms_output.put_line函数输出只能是字符串,因此利用to_char函数将数值型结果转换为字符型--   (2)字符表达式  字符表达式 字符表达式由字符型常数,变量,函数和字符运算符组 ...
--(1)使用%type定义变量 -- declare n_name users.usedname%type; begin commit; end;  --(2)定义记录类型变量 -- declare --定义了名为myrecord的记录类型,该记录类型由整数型的myrecordnumber和日期型的mycurrentdate基本类型变量组成 type myrecord is record( myrecordnumber int, mycurrentdate date); --然后声明一个myrecord类型的变量; srecord myrecord; b ...
查询各个部门的总员工和总薪水占整个公司的比率:   SELECT a.department_id "Department", a.num_emp/b.total_count "%_Employees", a.sal_sum/b.total_sal "%_Salary" FROM (SELECT department_id, COUNT(*) num_emp, SUM(salary) sal_sum FROM employees GROUP BY department_id) a, (SELECT ...
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); 将Date型数据转化成为String类型 String s_date=sdf.format(new Date()); 将String型数据转化成为Date类型 Date d_date=sdf.parse(s_date); 备注: 比较两个时间可以用 Date date_1= new Date(); Date date_2= new Date(); Boolean: date_1.before(date_2) date_2.after(date_1); ...
package Hash; public class Demo{ int value; int id; public Demo(int _id,int _value){ this.id=_id; this.value=_value; } public String toString(){ return "value="+value; } // public boolean equals(Object o){ // Demo d=(Demo)o; // return (d.value==value)?true:false; // } / ...
Global site tag (gtag.js) - Google Analytics