data_sub在Oracle,Oracle系列之一-Datatype And Subprogram

Oracle系列之一----Datatype And Subprogram

Oracle系列之一----Datatype And Subprogram:http://overshit.iteye.com/admin/blogs/932585;

Oracle系列之二----Exception And Expression:http://overshit.iteye.com/admin/blogs/932605;

Oracle系列之三----Implicit Cursor:http://overshit.iteye.com/admin/blogs/932609;

Oracle系列之四----Dynamic Cursor:http://overshit.iteye.com/admin/blogs/932610;

Oracle系列之五----Cursor And Variable:http://overshit.iteye.com/admin/blogs/932612;

Oracle系列之六----Procedure--Package--Purity:http://overshit.iteye.com/admin/blogs/932615;

Oracle系列之七----Trigger:http://overshit.iteye.com/admin/blogs/932616;

请先查看Oracle系列之零:Oracle体系结构

请先在Oracle 10g下创建用户:housesale,密码为housesale,赋予DBA Permission

115038738.jpg

----1:---------------------------------------------

declare

v_date date;

begin

v_date := sysdate + 1;

dbms_output.put_line(v_date);

end;

select sysdate from dual;

----2:---------------------------------------------

----declare

declare

v_custname varchar2(50);

begin

----execute

select cust.custname into v_custname

from customer cust

where cust.custid = 96;

dbms_output.put_line('custname:' || v_custname);

----deal with exception

Exception

when no_data_found then

dbms_output.put_line('This customer does not exists!');

end;

----3:---------------------------------------------

subprogram(procedure,function,trigger,package)

----3.1:procedure----

create or replace procedure update_age(p_custname varchar2,p_newAge number)

is

begin

update customer set custage = p_newAge

where custname = p_custname;

commit;

end;

----execute this sql in sql command

execute update_age('彭海燕',20);

----execute this sql in sql edit

call update_age('彭海燕',18);

----3.2:function----

create or replace function func_add(param number)

return number

as

begin

return param + 10;

end;

select func_add(10) from dual;

select func_add(custage) from customer where custid = 96;

----3.3:trigger----

create or replace trigger tri_cust_update

before update or delete on customer

for each row

declare

begin

if(:old.custage > :new.custage) then

raise_application_error('-20001','age can not reduce,add it!');

end if;

end;

----test expression

update customer set custage = '80' where custid = 96;

select * from customer where custid = 96;

----3.4:package----

----package head such as interface in Java

create or replace package pack_add

is

function func_add(param number)

return number;

end;

----and package body implements interface

create or replace package body pack_add

is

function func_add(param number)

return number

as

begin

return param + 10;

end;

end;

select pack_add.func_add(50) from dual;

select pack_add.func_add(custage) from customer where custid = 96;

----4:query oracle character-----------------------

login as system administrator

select name,value$ from props$ where name like '%NLS%'

----5:datatype and ‎variable------------------------

----5.1:collection type----

declare

Type customer_table_type is table of customer.custage%type index by binary_integer;

custtype customer_table_type;

begin

----operator index ‎directly

select custage into custtype(-1) from customer where custname = '彭海燕' and custid = 96;

dbms_output.put_line('custage is: ' || custtype(-1));

----let query result insert into collection directly

select custage bulk collect into custtype from customer;

dbms_output.put_line('custage is: ' || custtype(1));

dbms_output.put_line('count is: ' || custtype.count);

end;

declare

Type customer_table_type is table of customer.custage%type index by binary_integer;

custtype customer_table_type;

begin

----operator index ‎directly

select custage into custtype(-1) from customer where custname = '彭海燕' and custid = 96;

dbms_output.put_line('custage is: ' || custtype(-1));

----let query result insert into collection directly

select custage bulk collect into custtype from customer;

for i in custtype.first..custtype.last

loop

dbms_output.put_line('The ' || i || ' position is ' || custtype(i));

end loop;

end;

----5.2 LOB datatype-------------------------------

drop table bfile_tab;

drop table utl_lob_test;

grant create any directory to housesale;

grant create any library to housesale;

create or replace directory meilin_dir as 'D:\\ora';

create table bfile_tab(bfile_column bfile);

create table utl_lob_test(blob_column blob);

----execute expression as follows will insert picture into utl_lob_test blob_column column as d:\ora catalog

declare

a_blob blob;

----MEILIN_DIR must be uppercase,and you should put meilin.jpg as path:'D:/ora/meilin.jpg'

a_bfile bfile := bfilename('MEILIN_DIR','meilin.jpg');

begin

insert into bfile_tab values(a_bfile)

returning bfile_column into a_bfile;

insert into utl_lob_test values (empty_blob())

returning blob_column into a_blob;

dbms_lob.fileopen(a_bfile);

dbms_lob.loadfromfile(a_blob,a_bfile,dbms_lob.getlength(a_bfile));

dbms_lob.fileclose(a_bfile);

commit;

end;

select * from utl_lob_test;

115038739.jpg

注:Oracle对LOB字段类型的的处理:这里做个入门,对Java操作LOB类型字段请查看:

JDBC operator oracle LOB column:http://overshit.iteye.com/admin/blogs/932619

----6:---------------------------------------------

create or replace procedure house_count

as

v_houCount number(10);

begin

select count(*) into v_houCount from house;

dbms_output.put_line('house;' || v_houCount);

end;

execute house_count;

----2:call procedure at hr account

grant execute on house_countto hr;

----login hr

begin

housesale.house_count;

end;

create or replace procedure house_list

as

cursor house_cursor is

select housenumber,housetype,edificeid from house where housenumber <105 and housetype > 0 and edificeid < 3;

begin

for house_record in house_cursor loop

dbms_output.put_line('housenumber = [' || house_record.housenumber || '] ---- housetype = [' || house_record.housetype || ']');

end loop;

house_count;

end;

select * from house

----7:nine nine multiplication table---------------

begin

for i in 1..9 loop

for j in 1..i loop

dbms_output.put('' || j || '*' || i || '=' || j*i || ' ');

end loop;

dbms_output.put_line('');

end loop;

end;

Oracle系列SQL及数据库下载:http://download.csdn.net/source/3046868

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
jackson-datatype-jdk8是一个用于处理Java 8日期/时间类型的Jackson模块。它可以让Jackson库支持Java 8的日期和时间类,例如LocalDateTime。 如果你想在项目中使用jackson-datatype-jdk8,你需要将相应的jar包添加到你的项目依赖中。你可以通过赠送的jar包,例如jackson-datatype-jdk8-2.11.4.jar,jackson-datatype-jdk8-2.11.4-javadoc.jar和jackson-datatype-jdk8-2.11.4-sources.jar来获取这些jar包的文件。 同时,你还需要在你的项目的pom.xml文件中配置相应的依赖项,例如在dependencies标签中添加以下代码片段: <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.8</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.datatype</groupId> <artifactId>jackson-datatype-jdk8</artifactId> <version>2.8.8</version> </dependency> 这样配置之后,你的项目就可以正常使用jackson-datatype-jdk8模块来处理Java 8的日期和时间类型了。如果在使用过程中出现问题,例如报错"Java 8 date/time type `java.time.LocalDateTime` not supported by default",你可以尝试添加Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"来启用对Java 8日期/时间类型的处理。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [jackson-datatype-jdk8-2.11.4-API文档-中文版.zip](https://download.csdn.net/download/qq_36462452/86109534)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [ssm 开发经验 ...](https://blog.csdn.net/weixin_39452731/article/details/92012138)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [解决JDK8中LocalDateTime(反)序列化问题,报错com.fasterxml.jackson.datatype:jackson-datatype-jsr310](https://blog.csdn.net/rolling_kitten/article/details/128648303)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值