--存储过程
1.不带参:
create or replace procedure 存储过程名
as|is
--说明部分
begin
--执行的语句;
end; 调用存储过程 1 execute 存储过程名
--exec 存储过程名 2 在另外的plsql语句中直接调用 begin
存储过程名;
存储过程名;
存储过程名;
end; create or replace procedure p_dept
as
begin
dbms_output.put_line('存储过程');
end; 2.带参的存储过程 create or replace procedure 存储过程名 (参数 in|out 参数类型)
as|is
--说明部分
begin
--执行的语句;
end; --eg:
create or replace procedure p_dept1 (nuo in number)
as
--说明部分
v_english dept.english%type;
begin
--执行的语句; --修改前的分数
select english into v_english from dept where id=nuo;
--修改后的分数
update dept set english=english+10 where id=nuo;
--打印
dbms_output.put_line('修改前分数为:'||v_english||'修改后的分数为'||(v_english+10)); end;
in和out的区别 --创建一个不带参的函数 create or replace function f_dept
--返回的是一个类型
return number
as
--说明部分
--定义一个变量来接收分数
v_english dept.english%type; begin
select english into v_english from dept where name1='杨雾';
dbms_output.put_line(v_english);
return v_english;
end; --存储过程调用out方法实现返回多个值
create or replace procedure p_dept2 (nuo in number,
v_name out varchar2,
v_english out number,
v_math out number) as
--说明部分
begin
--执行的语句; --修改前的分数
select name1,english,math into v_name,v_english,v_math from dept where id=nuo; end;
-- 存储过程
create or replace procedure p_score
is v_math number;
begin
select math into v_math from scores where id=3;
dbms_output.put_line(v_math);
end; -- 带参储存过程
create procedure p_score2(digital in number)
as v_chinese number;
begin
select chinese into v_chinese from scores where id=digital;
dbms_output.put_line(v_chinese);
end; --存储过程调用out方法返回多个值
create or replace procedure
p_score3(v_id in number,v_english out number,v_chinese out number)
as v_math number;
begin
select math,chinese,english into v_math,v_chinese,v_english from scores
where id = v_id;
dbms_output.put_line('Math:'||v_math||','||'Chinese:'||v_chinese||','||'English:'||v_english);
end; -- 函数
create or replace function f_score
return number
as
v_english scores.english%type;
begin
select english into v_english from scores where id = 5;
return v_english;
end; -- 带参函数
create or replace function f_score2(digital in number)
return scores.english%type
as
v_english number;
begin
select english into v_english from scores where id = digital;
return v_english;
end;

PL/SQL 存储函数和过程的更多相关文章

  1. Netsuite Formula > Oracle函数列表速查(PL/SQL单行函数和组函数详解).txt

    PL/SQL单行函数和组函数详解 函数是一种有零个或多个参数并且有一个返回值的程序.在SQL中Oracle内建了一系列函数,这些函数都可被称为SQL或PL/SQL语句,函数主要分为两大类: 单行函数 ...

  2. oracle数据库之存储函数和过程

    一.引言     ORACLE 提供可以把 PL/SQL 程序存储在数据库中,并可以在任何地方来运行它.这样就叫存储过程或函数.过程和函数统称为 PL/SQL 子程序,他们是被命名的 PL/SQL 块 ...

  3. PL/SQL之--函数

    一.函数 函数是作为数据库对象存储在oracle数据库中,函数又被称为PL/SQL子程序.oracle处理使用系统提供的函数之外,用户还可以自己定义函数.函数通常被作为一个表达式来调用或存储过程的一个 ...

  4. PL/SQL自定义函数

    从SQL表达式中调用函数的限制 为了从SQL表达式中调用函数,一个用户定义函数必须: 是存储函数 只接受IN函数 只接收有受的SQL数据类型,而不接受PL/SQL数据类型 返回数据类型为有效的SQL数 ...

  5. oracle pl/sql split函数

    在软件开发过程中程序员经常会遇到字符串的拼接和拆分工作. 以java开发为例: 前台传入字符串拼接形式的一个JSON数据,如:"1001,1002,1003",这可能代表了一组序号 ...

  6. Oracle PL/SQL,游标,过程

    1.PL/SQL  语法相关 -- SQL 语言只是访问,操作数据库的语言,而比并不是程序设计语言,因此不能用于程序开发. -- PL/SQL 是在标准SQl语言上进行过程性扩展后形成的程序设计语言, ...

  7. PL/SQL编程—函数

    SQL> select * from mytest; ID NAME PASSWD SALARY ----- -------------------- -------------------- ...

  8. PL/SQL 06 函数 function

    --函数 create or replace function  函数名称(参数1 类型1,参数2 类型2,...)  return 数据类型as  变量.常量声明;begin  代码;end; cr ...

  9. oracle 学习(三)pl/sql语言函数

    系统内置函数 数学运算函数 字符串函数 统计函数 日期函数 用户定义函数:存储在数据库中的代码块,可以把值返回到调用程序.调用时如同系统函数一样 参数模式 IN模式:表示该参数时输入给函数的参数 OU ...

随机推荐

  1. A Simple C++ Template Class that Matches a String to a Wildcard Pattern

    A recently implemented enhanced wildcard string matcher, features of which including, Supporting wil ...

  2. HttpLuaModule 获取Get和Post参数

    Get方式: local id = tostring(ngx.var.arg_id) local type = tostring(ngx.var.arg_type) Post方式: ngx.req.r ...

  3. [Leetcode] Maximum Gap

    Given an unsorted array, find the maximum difference between the successive elements in its sorted f ...

  4. POJ 1329 Circle Through Three Points(三角形外心)

    题目链接 抄的外心模版.然后,输出认真一点.1Y. #include <cstdio> #include <cstring> #include <string> # ...

  5. 不错的 iOS 开发辅助工具

    一,常用 1>  iPhone 日志插件iConsole.

  6. 谷歌(GDG):智能技术在物联网及移动互联网中的最新应用讲座

       谷歌开发者社区GDG(原谷歌技术用户组GTUG),将于11月23日(周六)下午 1:30-5:00,在北京翠宫饭举办一场智能技术在物联网及移动互联网中的最新应用讲座,培训讲座中将通过三个专题与众 ...

  7. GO语言练习:构建json 和 解析JSON 实例

    本文介绍如何使用Go语言自带的库把对象转换为JSON格式,并在channel中进行传输后,并把JSON格式的信息转换回对象. 1.Go语言的JSON 库 Go语言自带的JSON转换库为 encodin ...

  8. asp.net分页方法

    /// </summary> /// <param name="ds">DataSet实例</param> /// <param name ...

  9. XAML parser exception

    To debug xaml exception: Visual Studio -> Debug -> Exception -> Common Language Runtime Exc ...

  10. 让你的APP支持iPhone5

    让你的APP支持iPhone5 前言 国庆节前,为了支持 iPhone5 的屏幕分辨率 (640 象素 x 1136 象素),我尝试着升级粉笔网 iPhone 客户端.整个过程花了大概一天的时间,我把 ...