【PL/SQL】 INSERT IN PROCEDURE Analysis & Example | oracle数据库: 用procedure插入数据的案例分析
2019-06-20 04:28
901 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yawen9790/article/details/92896605
/* procedure practice */ --display original table select * from regions; --test sequence before declare the procedure drop sequence s_regions; create sequence s_regions start with 12 increment by 1 cache 2; --ceshi procedure create or replace procedure ceshi( p_id regions.region_id%type, p_name regions.region_name%type) IS --temp to store the value from sequence 1 --not working tem number; --ceshia begin insert into regions values (10, 'qin'); --v2 --all or following insert into regions values (p_id, p_name); --v3 --try sequence after insert into regions values (s_regions.nextval, 'wei'); insert into regions values (s_regions.nextval, 'qi'); insert into regions values (s_regions.nextval, 'yan'); insert into regions values (s_regions.nextval, 'han'); --tem := S_REGIONS.nextval; --try to creat a sequence inside of block /* adding the following block will cause line 36 error execute immediate 'create sequence s2';-- start with 20 increment by 1'; select s2.nextval into tem from dual; tem := tem + 50; insert into regions values (tem, 'qi'); */ end ceshi; / --test 1 --not working --nothing chnages select * from regions; --the folloing line is not working --since the prroedure is not executing --the rollback is meaning less --rollback; --/ --test 4 --whether rollback working --no --select * from regions; --also --the sequence does not work here --coz this is used in the definition body of procedure --move it before the procedure /* create sequence s_regions start with 12 increment by 1 nocache; */ --te --test 2 --working --qin is added --zhao is added execute ceshi(11, 'zhao'); select * from regions; --reset table to init --and test whether it works --works rollback; / select * from regions; --manualy delete in case does not write rollback process --test the table again /* delete from regions where region_id in (10,11); select * from regions; */ --try sequence --not working if processed after execute the procedure --deleted this and move it before procedure --drop sequence s_regions; /* create sequence s_regions start with 12 increment by 1 nocache; */
相关文章推荐
- PL/SQL】DELETE IN PROCEDURE Analysis & Example | oracle数据库: 用procedure删除数据的案例分析
- 【PL/SQL】ME IN PROCEDURE Analysis & Example | oracle数据库: 用procedure合并数据的案例分析GE
- 【PL/SQL】 UPDATE IN PROCEDURE Analysis & Example | oracle数据库: 用procedure修改数据的案例分析
- 【PL/SQL】 ROLLBACK WHEN EXECUTE A PROCEDURE Analysis & Output | oracle数据库: 回滚案例的输出与分析
- hibernate 实行原生sql insert数据无法插入到数据库
- oracle 数据库的管理工具 PL/SQL_Developer 的简易使用 与Java 连接并查询显示出数据
- Oracle 11g数据库使用pl/sql developer进行数据导入与导出
- Demo of use SQL (Insert logs in system resource usage table)使用sql 的一个示例(插入系统使用日志数据)
- 用PL/SQL Developer 把oracle表里的数据导成insert语句
- 数据库编程实战:Oracle PL/SQL入门之案例实践
- oracle 数据库数据类型和PL/SQL数据类型
- oracle数据库批量插入数据,及pl/sql Developer、python连接教程 含源码 -- 数据库
- PL/SQL使用INSERT...SELECT一次插入多行数据
- Oracle数据库案例整理-执行Oracle脚本失败或异常-使用SQL语句插入中文后数据库中显示乱码
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- 用PL/SQL Developer 把oracle表里的数据导成insert语句
- Oracle pl/sql导入sql文件,插入更新数据,中文乱码问题解决方案
- 用PL/SQL Developer 把oracle表里的数据导成insert语句(不积跬步,无以至千里)
- insert into插入表,插入多条数据,sql插入表,插入多条数据,数据库插入表,插入多条数据
- Oracle中使用 PL/SQL Developer插入批量数据