create or replace procedure procedure_procedure
AS
i_count integer;
begin
select count(*) into i_count from user_objects t where t.OBJECT_TYPE ='PROCEDURE' and t.OBJECT_NAME = upper('procedure_name');
if i_count>0 then
EXECUTE IMMEDIATE 'drop procedure procedure_name';
end if;
end procedure_procedure;
/
call procedure_procedure();
drop procedure procedure_procedure;
CREATE OR REPLACE PROCEDURE procedure_name(TOPOADDS IN T_LIST,
TOPOUPDATES IN T_LIST,
TOPODELETES IN T_LIST,
STBDELETES IN T_LIST,
STBREGIONUPDATE in T_LIST,
TOPORESULT OUT INTEGER) IS
V_TOTALCOUNT NUMBER(10);
TOPOINFO R_INFO;
STBINFO R_INFO;
V_SQL VARCHAR2(512);
V_TEMP_SQL VARCHAR2(512);
BEGIN
TOPORESULT := -1;
V_TOTALCOUNT := TOPODELETES.COUNT;
V_SQL := 'update tablename set expiretime=:1 WHERE nodename=:2 and ' ||
'expiretime=to_timestamp(''2099-01-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'')';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := TOPODELETES(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.EXPIRETIME, TOPOINFO.NODENAME;
END LOOP;
V_TEMP_SQL := 'insert into table_temp(FATHERNODENAME,EXPIRETIME)values(:1,:2)';
V_TOTALCOUNT := STBDELETES.COUNT;
FOR I IN 1 .. V_TOTALCOUNT LOOP
STBINFO := STBDELETES(I);
EXECUTE IMMEDIATE V_TEMP_SQL
USING STBINFO.NODENAME, STBINFO.EXPIRETIME;
END LOOP;
TOPORESULT := -2;
V_SQL := 'merge into tablename aa using table_temp temp on (aa.FATHERNODENAME = temp.FATHERNODENAME )' ||
' when matched then update set aa.expiretime=temp.expiretime ' ||
' where aa.expiretime = to_timestamp(''2099-01-01 00:00:00'', ''yyyy-mm-dd hh24:mi:ss'')';
EXECUTE IMMEDIATE V_SQL;
TOPORESULT := -3;
V_TOTALCOUNT := TOPOUPDATES.COUNT;
V_SQL := 'UPDATE table_name SET fathernodename=:1,nodetype=:2,nodeif=:3,fathernodeif=:4,' ||
'bakupnodename=:5,backupfathernodename=:6,backupnodeif=:7,backupfathernodeif=:8' ||
' WHERE nodename=:9 ' ||
' and expiretime=to_timestamp(''2099-01-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'')';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := TOPOUPDATES(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.FATHERNODENAME, TOPOINFO.NODETYPE, TOPOINFO.NODEIF, TOPOINFO.FATHERNODEIF, TOPOINFO.BAKUPNODENAME, TOPOINFO.BACKUPFATHERNODENAME, TOPOINFO.BACKUPNODEIF, TOPOINFO.BACKUPFATHERNODEIF, TOPOINFO.NODENAME;
END LOOP;
TOPORESULT := -4;
V_TOTALCOUNT := TOPOADDS.COUNT;
V_SQL := 'INSERT INTO tablename(nodename,fathernodename,nodetype,nodeif,fathernodeif,' ||
'bakupnodename,backupfathernodename,backupnodeif,backupfathernodeif,effectivetime,expiretime)' ||
'VALUES(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := TOPOADDS(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.NODENAME, TOPOINFO.FATHERNODENAME, TOPOINFO.NODETYPE, TOPOINFO.NODEIF, TOPOINFO.FATHERNODEIF, TOPOINFO.BAKUPNODENAME, TOPOINFO.BACKUPFATHERNODENAME, TOPOINFO.BACKUPNODEIF, TOPOINFO.BACKUPFATHERNODEIF, TOPOINFO.EFFECTIVETIME, TOPOINFO.EXPIRETIME;
END LOOP;
TOPORESULT := -5;
V_TOTALCOUNT := STBREGIONUPDATE.COUNT;
V_SQL := 'update tablename t set t.regionname = :1 where t.fathernodename = :2 and expiretime=to_timestamp(''2099-01-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'')';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := STBREGIONUPDATE(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.REGIONNAME, TOPOINFO.NODENAME;
END LOOP;
COMMIT;
TOPORESULT := 0;
EXCEPTION
WHEN OTHERS THEN
BEGIN
ROLLBACK;
CONST.LOG_ERROR_TO_TABLE(SQLCODE, SQLERRM, V_SQL);--调用包const中的procedure
TOPORESULT := -6;
END;
END procedure_name;
/
AS
i_count integer;
begin
select count(*) into i_count from user_objects t where t.OBJECT_TYPE ='PROCEDURE' and t.OBJECT_NAME = upper('procedure_name');
if i_count>0 then
EXECUTE IMMEDIATE 'drop procedure procedure_name';
end if;
end procedure_procedure;
/
call procedure_procedure();
drop procedure procedure_procedure;
CREATE OR REPLACE PROCEDURE procedure_name(TOPOADDS IN T_LIST,
TOPOUPDATES IN T_LIST,
TOPODELETES IN T_LIST,
STBDELETES IN T_LIST,
STBREGIONUPDATE in T_LIST,
TOPORESULT OUT INTEGER) IS
V_TOTALCOUNT NUMBER(10);
TOPOINFO R_INFO;
STBINFO R_INFO;
V_SQL VARCHAR2(512);
V_TEMP_SQL VARCHAR2(512);
BEGIN
TOPORESULT := -1;
V_TOTALCOUNT := TOPODELETES.COUNT;
V_SQL := 'update tablename set expiretime=:1 WHERE nodename=:2 and ' ||
'expiretime=to_timestamp(''2099-01-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'')';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := TOPODELETES(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.EXPIRETIME, TOPOINFO.NODENAME;
END LOOP;
V_TEMP_SQL := 'insert into table_temp(FATHERNODENAME,EXPIRETIME)values(:1,:2)';
V_TOTALCOUNT := STBDELETES.COUNT;
FOR I IN 1 .. V_TOTALCOUNT LOOP
STBINFO := STBDELETES(I);
EXECUTE IMMEDIATE V_TEMP_SQL
USING STBINFO.NODENAME, STBINFO.EXPIRETIME;
END LOOP;
TOPORESULT := -2;
V_SQL := 'merge into tablename aa using table_temp temp on (aa.FATHERNODENAME = temp.FATHERNODENAME )' ||
' when matched then update set aa.expiretime=temp.expiretime ' ||
' where aa.expiretime = to_timestamp(''2099-01-01 00:00:00'', ''yyyy-mm-dd hh24:mi:ss'')';
EXECUTE IMMEDIATE V_SQL;
TOPORESULT := -3;
V_TOTALCOUNT := TOPOUPDATES.COUNT;
V_SQL := 'UPDATE table_name SET fathernodename=:1,nodetype=:2,nodeif=:3,fathernodeif=:4,' ||
'bakupnodename=:5,backupfathernodename=:6,backupnodeif=:7,backupfathernodeif=:8' ||
' WHERE nodename=:9 ' ||
' and expiretime=to_timestamp(''2099-01-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'')';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := TOPOUPDATES(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.FATHERNODENAME, TOPOINFO.NODETYPE, TOPOINFO.NODEIF, TOPOINFO.FATHERNODEIF, TOPOINFO.BAKUPNODENAME, TOPOINFO.BACKUPFATHERNODENAME, TOPOINFO.BACKUPNODEIF, TOPOINFO.BACKUPFATHERNODEIF, TOPOINFO.NODENAME;
END LOOP;
TOPORESULT := -4;
V_TOTALCOUNT := TOPOADDS.COUNT;
V_SQL := 'INSERT INTO tablename(nodename,fathernodename,nodetype,nodeif,fathernodeif,' ||
'bakupnodename,backupfathernodename,backupnodeif,backupfathernodeif,effectivetime,expiretime)' ||
'VALUES(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11)';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := TOPOADDS(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.NODENAME, TOPOINFO.FATHERNODENAME, TOPOINFO.NODETYPE, TOPOINFO.NODEIF, TOPOINFO.FATHERNODEIF, TOPOINFO.BAKUPNODENAME, TOPOINFO.BACKUPFATHERNODENAME, TOPOINFO.BACKUPNODEIF, TOPOINFO.BACKUPFATHERNODEIF, TOPOINFO.EFFECTIVETIME, TOPOINFO.EXPIRETIME;
END LOOP;
TOPORESULT := -5;
V_TOTALCOUNT := STBREGIONUPDATE.COUNT;
V_SQL := 'update tablename t set t.regionname = :1 where t.fathernodename = :2 and expiretime=to_timestamp(''2099-01-01 00:00:00'',''yyyy-mm-dd hh24:mi:ss'')';
FOR I IN 1 .. V_TOTALCOUNT LOOP
TOPOINFO := STBREGIONUPDATE(I);
EXECUTE IMMEDIATE V_SQL
USING TOPOINFO.REGIONNAME, TOPOINFO.NODENAME;
END LOOP;
COMMIT;
TOPORESULT := 0;
EXCEPTION
WHEN OTHERS THEN
BEGIN
ROLLBACK;
CONST.LOG_ERROR_TO_TABLE(SQLCODE, SQLERRM, V_SQL);--调用包const中的procedure
TOPORESULT := -6;
END;
END procedure_name;
/
发表评论
-
执行sql文件
2011-11-06 16:52 930spool $HOME/logs/createtables.l ... -
创建package样例
2011-11-06 16:50 557create or replace procedure pac ... -
创建sequence样例
2011-11-06 16:52 630create or replace procedure seq ... -
创建同义词样例
2011-11-06 16:52 909create or replace procedure syn ... -
alter table tablename cache
2011-11-01 16:33 0oracle有3种buffer pool 1.default ... -
truncate和delete的区别
2011-11-01 16:13 1438删除表中数据的方法有delete和truncate,delet ... -
FlashBack table的一点理解
2011-11-01 14:52 8171.Flashback Table功能描述 ... -
对row movement的一点理解
2011-11-01 14:26 1831ROW MOVEMENT特性最初是在8i时引入的,其目的是提高 ... -
创建表样例
2011-11-01 14:07 773create or replace procedure tab ... -
创建临时表样例
2011-11-01 11:06 1171Oracle8i及以上版本中可 ... -
创建自定义类型样例
2011-10-31 19:38 729create or replace procedure typ ... -
创建视图样例
2011-10-31 19:22 844create or replace view view_nam ... -
创建job样例
2011-10-31 19:19 819CREATE OR REPLACE PROCEDURE job ... -
创建函数样例
2011-10-31 19:14 524create or replace procedure fun ...
相关推荐
2. **创建存储过程**:使用`CREATE PROCEDURE`语句创建。比如,创建一个简单的存储过程,用来更新表中特定记录的值: ```sql CREATE PROCEDURE update_value (IN id INT, IN new_value VARCHAR(50)) MODIFIES SQL...
SQL样例表脚本通常包含了一系列的CREATE TABLE语句,用于创建具有不同结构的数据库表格。这些脚本可能还会包括INSERT INTO语句,用来填充表格的数据,以模拟实际场景。例如,一个典型的样例表脚本可能会创建员工、...
这个"sqlserver脚本样例.rar"压缩包显然包含了与SQL Server相关的学习脚本,可能涵盖了创建数据库、表,数据操作,查询,索引,存储过程,触发器等各种SQL语句的实例。下面我们将深入探讨这些关键知识点。 1. **...
`CREATE PROCEDURE` 用于创建存储过程,`EXEC` 或 `EXECUTE` 用于执行。通过存储过程,你可以封装常用操作,提高代码重用性。 索引是提升查询效率的关键。非聚簇索引和聚簇索引分别有不同的特点和用途。`CREATE ...
西门子RPC开发样例文档主要涉及的是利用RPC(Remote Procedure Call)技术与SINUMERIK控制器进行通信的方法。RPC是一种平台中立的标准,允许不同系统间的远程调用,使得主机计算机能够与SINUMERIK控制器进行数据交换...
GWT,全称为Google Web Toolkit,是一个开源的Java框架,用于构建高性能的、富...通过学习和理解这些样例,开发者不仅可以掌握GWT的基本用法,还能进一步了解如何利用GWT创建高性能、响应式的Web应用,提升开发效率。
RPC(Remote Procedure Call)是一种进程间通信(IPC)技术,允许程序在不同的计算机上通过网络进行通信,就像调用本地函数...通过学习和实践这些资源,你可以掌握如何创建和使用RPC服务,从而提高你的网络编程技能。
1. **创建数据库**: 使用`CREATE DATABASE`语句创建新的数据库。例如: ``` CREATE DATABASE MyDatabase; ``` 2. **选择数据库**: 使用`USE`语句切换到要操作的数据库。 ``` USE MyDatabase; ``` 3. **...
本资料"SQL语言学习样例数据.rar"包含两个文本文件,"populate.txt"和"create.txt",分别用于创建数据库结构和填充数据,是学习SQL语句DML(Data Manipulation Language)的良好实践。 首先,"create.txt"文件中...
首先,存储过程(Stored Procedure)是一组预编译的SQL语句,可以接受参数,执行特定任务并返回结果。在给定的示例中,`insert_userinfo` 是一个存储过程,用于处理用户注册。它检查新用户名是否已存在,如果不存在...
创建存储过程需要使用 CREATE PROCEDURE 语句。以下是一个创建存储过程的示例: CREATE PROCEDURE GetCustomerOrders ( IN customerId INT ) CALL GetCustomerOrders(1234); 存储过程中使用变量: 可以在...
- 创建一个新的DataWindow对象,选择"SQL Select"类型,并在SQL文本框中输入存储过程的名称,如`EXEC YourProcedureName`。 - 在"Datawindow Painter"中,定义数据列,这些列将对应于存储过程返回的结果集。 - ...
CREATE OR REPLACE PROCEDURE procedure_name ( parameter1 IN data_type, parameter2 OUT data_type, ... ) IS -- 声明变量 variable1 data_type; variable2 data_type; BEGIN -- 过程体 -- 包括SQL语句和...
4. KeInsertQueueDpc 和 KeRemoveQueueDpc:这两个API用于在内核态调度DPC(Deferred Procedure Calls)。DPC是异步执行的低优先级内核线程,适合在驱动中处理I/O请求或其他延迟任务。 5. IoCreateDevice 和 ...
接着,我们创建了一个简单的 PL/SQL 程序,删除某门课程的过程,并执行了一个样例。 在PL/SQL编程语言中,我们可以使用过程来完成一些特定的操作。在本实验中,我们创建了一个过程来删除某门课程。该过程的代码如下...
6. **存储过程(PROCEDURE)和函数(FUNCTION)**:学习编写和调用存储过程及自定义函数,实现数据处理的复杂逻辑,提高代码复用性。 7. **事务(TRANSACTION)与并发控制**:理解事务的ACID属性(原子性、一致性、...
对象可以通过`Object`类操作,而调用过程则需要创建`Procedure`对象,设置输入/输出参数并执行。 总的来说,Oracle的OCCI函数库为开发者提供了强大的工具,用于在C++应用程序中高效地操作Oracle数据库。通过熟练...
3. **窗口过程(Window Procedure)**:每个窗口都有一个关联的窗口过程函数,它处理来自操作系统的消息。在汇编代码中,需要定义这个函数并使用`WndProc`伪指令。 4. **资源管理**:如动态内存分配(`LocalAlloc`)...
RPC(Remote Procedure Call)是远程过程调用,它允许一个程序在执行时调用另一个位于不同计算机上的程序,使得分布式系统中的组件可以相互通信。Windows RPC是微软提供的一个跨平台、面向对象的通信框架,它允许...
HR(Human Resources)数据库是一个示例数据库,通常在Oracle安装过程中作为标准样例提供,用于帮助用户熟悉Oracle SQL查询语言和数据库管理。如果你在你的Oracle默认数据库中缺少HR数据库,可以通过导入提供的"HR...