pl/sql 实例解析 01
2024-08-27 20:44:47
1. 合并 firstname, lastname.
1: declare
2: v_first_name varchar2(255);
3: v_last_name varchar2(255);
4: begin
5: select first_name, last_name
6: into v_first_name, v_last_name
7: from student
8: where student_id = 777;
9:
10: dbms_output.put_line('Student Name: ' || v_first_name || ' ' || v_last_name);
11: exception
12: when no_data_found then
13: dbms_output.put_line('There is no data');
14: end;
15: /
16: show errors;
2. 使用替代变量, 交互内容, 个人感觉替代变量并不常用, 真正生产情况时, 那有那么多人来输入替代变量的值啊.
/*
* 测试替代变量
* sv_student_id, sv 个人理解是 system value的意思
*/ declare
v_student_id number := &sv_student_id;
v_first_name varchar2(255);
v_last_name varchar2(255);
begin
select first_name, last_name
into v_first_name, v_last_name
from student
where student_id = &sv_student_id; dbms_output.put_line('Student Name: ' || v_first_name || '' || v_last_name);
exception
when no_data_found then
dbms_output.put_line('There is no student');
end;
/
show errors;
注意: 运行以上例子2 时, 系统会给出提示, 让你输入 student_id 的值, 然后会显示 old_value, new_value
最新文章
- Error: pathspec '*' did not match any file(s) known to git.
- 数据字典生成工具之旅(3):PowerDesign文件组成结构介绍及操作
- MongoDB创建数据库和集合命令db.createCollection详解(转)
- 【C语言】12-指向一维数组元素的指针
- 删除下标为n的数组值
- Marriage Match IV---hdu3416(spfa + Dinic)
- cmd下windows批处理,获取当前系统时间,生成日志文件名
- cocos2d-x触屏事件(单点触屏)
- IAR Embedded Workbench 破解方法+工具+授权文件
- CSS入门教程——定位(positon)
- The following classes could not be found: - android.support.v7.internal.widget.ActionBarOverlayLayou解决方案
- 华为OJ之最长公共子序列
- 庞玉栋:浅谈seo优化对于网站建设的重要性
- Go语言中定时器cron的基本使用
- [java] 数据处理
- 无限极分类php实现—查子孙树、家谱树
- 124、@JavascriptInterface
- Struts2重新学习之自定义拦截器(判断用户是否是登录状态)
- AT994 【11の倍数】
- weblogic安装使用: Could not Create the Java Virtual Machine
热门文章
- SVN-两种存储方式的比较(BDB vs. FSFS)
- HTML5 移动端如何使用css让百分比布局的弹窗水平和垂直方向上居中
- php使用curl请求数据(采集数据)
- ES6 变量解构用法
- 关于苹果开发证书失效的解决方式(2016年2月14日Failed to locate or generate matching signing assets)
- [Exception Android 22] - Could not find com.android.support:design:23.1.1
- Hibernate映射set与List
- bootstrap学习笔记一 登录水平表单
- 【转】可在广域网部署运行的即时通讯系统 -- GGTalk总览(附源码下载)
- VMware配置网络的3种方式:NAT、Host-Only、Bridged