11g 新特性之 plsql

  

This day I will introduce the 11G plsql:

Step1:
  Let us create one sequence first:
  create sequence dept_seq start with 101;
 
  Now I had viewed the sequence had created in left side: SEQENCE
 
Step2:
  Create one procedure:
 
  create or replace procedure add_dept(
       p_name IN dept.dname%TYPE,
       P_loc  IN dept.loc%TYPE ) IS
BEGIN
       INSERT INTO DEPT(DEPTNO,DNAME,LOC)
       VALUES (dept_seq.nextval,P_NAME,P_LOC);
END add_dept;
/

Now I had viewed the procedure had created in left side: procedure

Step3:
  Let us do a test for this procedure:
  1: Passing parameters using the positional notation.
   execute add_dept ('training',2500)
  2: Passing parameter using the named notation.
    execute add_dept (p_loc=>2400,p_name=>'EDUCATION')
   
Attention:
  Before 11g, Only position notation can used, after 11g, the named notation can be used:

 
SQL> execute add_dept ('t','shp');
 
begin add_dept ('t','shp'); end;
 
ORA-01438: 值大于为此列指定的允许精度
ORA-06512: 在 "SCOTT.ADD_DEPT", line 5
ORA-06512: 在 line 2

SQL> DESC DEPT;
 名称                                      是否为空? 类型
 ----------------------------------------- -------- -------------
 DEPTNO                                    NOT NULL NUMBER(2)
 DNAME                                              VARCHAR2(14)
 LOC                                                VARCHAR2(13)
 
the length of deptno is number(2), so the root cause is this, we start the sequece with 101,
we recreated the sequence with 01 is okay:

  1: drop sequence dept_seq
  2: create sequence dept_seq start with 01;
 
Step4:
  Let us open a command window to do this test:
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenghuiping2001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值