1.在oracle中,数据表别名不能加as,如:

select a.appname from appinfo a;-- 正确
select a.appname from appinfo as a;-- 错误

也许,是怕和oracle中的存储过程中的关键字as冲突的问题吧

2.在存储过程中,select某一字段时,后面必须紧跟into,如果select整个记录,利用游标的话就另当别论了。

  select af.keynode into kn from APPFOUNDATION af where af.appid=aid and af.foundationid=fid;-- 有into,正确编译
  select af.keynode from APPFOUNDATION af where af.appid=aid and af.foundationid=fid;-- 没有into,编译报错,提示:Compilation 
  Error: PLS-00428: an INTO clause is expected in this SELECT statement

3.在利用select...into...语法时,必须先确保数据库中有该条记录,否则会报出"no data found"异常。

   可以在该语法之前,先利用select count(*) from 查看数据库中是否存在该记录,如果存在,再利用select...into...

4.在存储过程中,别名不能和字段名称相同,否则虽然编译可以通过,但在运行阶段会报错

 select keynode into kn from APPFOUNDATION where appid=aid and foundationid=fid;-- 正确运行
select af.keynode into kn from APPFOUNDATION af where af.appid=appid and af.foundationid=foundationid;-- 运行阶段报错,提示
ORA-01422:exact fetch returns more than requested number of rows

5.在存储过程中,关于出现null的问题

假设有一个表A,定义如下:

create table A(
id varchar2(50) primary key not null,
vcount number(8) not null,
bid varchar2(50) not null -- 外键 
);

如果在存储过程中,使用如下语句:

select sum(vcount) into fcount from A where bid='xxxxxx';

如果A表中不存在bid="xxxxxx"的记录,则fcount=null(即使fcount定义时设置了默认值,如:fcount
number(8):=0依然无效,fcount还是会变成null),这样以后使用fcount时就可能有问题,所以在这里最好先判断一下:

if fcount is null then
    fcount:=0;
end if;

这样就一切ok了。

6.Hibernate调用oracle存储过程

        this.pnumberManager.getHibernateTemplate().execute(
                new HibernateCallback() {
                    public Object doInHibernate(Session session)
                            throws HibernateException, SQLException {
                        CallableStatement cs = session
                                .connection()
                                .prepareCall("{call modifyapppnumber_remain(?)}");
                        cs.setString(1, foundationid);
                        cs.execute();
                        return null;
                    }
                });

关于oracle存储过程的若干问题备忘的更多相关文章

  1. oracle 11g自动时间分区备忘

    一.时间date类型:create table spdb_demo(outBeginDate date,)partition by range(outBeginDate) interval(numto ...

  2. Oracle存储过程学习使用

    存储过程创建语法: create or replace procedure 存储过程名(param1 in type,param2 out type) as 变量1 类型(值范围); 变量2 类型(值 ...

  3. oracle存储过程 --1

    一,oracle存储过程语法   1.oracle存储过程结构  CREATE OR REPLACE PROCEDURE oracle存储过程名字 (     参数1 IN NUMBER,     参 ...

  4. oracle 存储过程的基本语法

    原文:oracle 存储过程的基本语法 1.基本结构 CREATE OR REPLACE PROCEDURE 存储过程名字(    参数1 IN NUMBER,    参数2 IN NUMBER) I ...

  5. Oracle 存储过程_(收集)

    oracle 存储过程的基本语法 1.基本结构 CREATE OR REPLACE PROCEDURE 存储过程名字(    参数1 IN NUMBER,    参数2 IN NUMBER) IS变量 ...

  6. ORACLE存储过程详解

    1.定义 所谓存储过程(Stored Procedure),就是一组用于完成特定数据库功能的SQL语句集,该SQL语句集经过编译后存储在数据库系统中.在使用时候,用户通过指定已经定义的存储过程名字并给 ...

  7. 项目中oracle存储过程记录——经常使用语法备忘

    项目中oracle存储过程记录--经常使用语法备忘 项目中须要写一个oracle存储过程,需求是收集一个复杂查询的内容(涉及到多张表),然后把符合条件的记录插入到目标表中.当中原表之中的一个的日期字段 ...

  8. .NET易忘备留 ORACLE存储过程调用

    1.Oracle存储过程调用[返回信息,单体或者列表] public IResult FundBuild(string partnerId,string userId, DateTime beginD ...

  9. Oracle存储过程学习备忘

    之前的项目使用存储过程很少,但在实际的项目中,存储过程的使用是必不可少的. 存储过程是一组为了完成特定功能的SQL 语句 集,经编译后存储在数据库中:存储过程创建后,一次编译在程序中可以多次调用,对安 ...

随机推荐

  1. 微信小程序开发系列七:微信小程序的页面跳转

    微信小程序开发系列教程 微信小程序开发系列一:微信小程序的申请和开发环境的搭建 微信小程序开发系列二:微信小程序的视图设计 微信小程序开发系列三:微信小程序的调试方法 微信小程序开发系列四:微信小程序 ...

  2. ACCEPT详解

    NAME 名称 accept - 在一个套接字上接收一个连接 SYNOPSIS 概述 #include <sys/types.h> #include <sys/socket.h> ...

  3. nginx 1.15.10 前端代理转发 将多个地址,代理转发到一个地址和端口 多系统公用一个cookie 统一token

    nginx 1.15.10 前端代理转发 将多个地址,代理转发到一个地址和端口 多系统公用一个cookie 统一token 注意: proxy_pass http://192.168.40.54:22 ...

  4. HTML基础(五)表单

    表单的工作原理 简单来说就是客户在浏览器输入信息之后,浏览器将用户在表单中的数据进行打包发送给服务器,服务器接收到之后进行处理,如下图 语法 <form> 表单元素</form> ...

  5. gcc 变量类型大小 练习 远离 cygwin64 需要带dll

    /* testmini.c -- very simple test program for the miniLZO library */ #include <stdio.h> #inclu ...

  6. linux 搜索文本

    find -type f -name '*.php'|xargs grep '127.0.0.1'  搜索所有.php 内容 127.0.0.1 转自:http://www.cnblogs.com/w ...

  7. day09 10 11 12 三天函数内容

    小括号.中括号名字()函数调用符[] 索引调用符 函数的注释:官方推荐: 查看注释 :funcming.__doc__      funcming.__name__ def func(name, ag ...

  8. 点击增加删除class

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. ubuntu修改网卡名称ensX为eth0

    1.sudo nano /etc/default/grub 找到GRUB_CMDLINE_LINUX="" 改为GRUB_CMDLINE_LINUX="net.ifnam ...

  10. Release Python Program as exe

    py2exe 可以用来将python program 以exe的形式发布. 安装py2exe 对于python 3.x pip install py2exe 可以直接安装 对于python 2.7, ...