如何更新存储过程中的游标?

时间:2012-06-19 04:54:39

标签: c#-4.0 stored-procedures oracle11g

我在oracle中有一个使用cursor的存储过程。当我通过C#代码调用它时,它正确地获取数据。但是如果表得到更新,那么我在C#应用程序中运行代码后也会得到旧值。我需要每次编译程序来获取更新的值... 有什么想法吗?

我的存储过程的PFB片段......

create or replace
PROCEDURE "SP_UTILITIES_LOG"
(
p_utility_name IN varchar2,
p_r_object_id IN varchar2,
p_platform_name IN varchar2,
p_exported_file_path IN varchar2,
p_Is_binary IN number,
p_extraction_status IN varchar2,
p_extraction_error IN varchar2,
p_extraction_datetime IN VARCHAR2,
p_schema_name IN varchar,
p_publication_path IN varchar,
p_schema_tcm_id IN varchar,
p_component_tcm_id IN varchar,
p_component_name IN varchar,
p_loading_status IN varchar,
p_transformed_file_path IN varchar,
p_transformed_status IN varchar,
p_import_status IN varchar,
p_loading_error IN varchar,
p_transform_error IN varchar,
p_import_error IN varchar,
p_loading_datetime IN TIMESTAMP,
p_transform_datetime IN TIMESTAMP,
p_import_datetime IN TIMESTAMP,
p_refcur out sys_refcursor
)
   IS  
   BEGIN

    IF(p_utility_name ='EXTRACTION')
    THEN
    BEGIN
   INSERT INTO utilities_log(R_OBJECT_ID,
PLATFORM_NAME,
EXPORTED_FILE_PATH,
IS_BINARY,
EXTRACTION_STATUS,
EXTRACTION_ERROR,
EXTRACTION_DATETIME
)
   VALUES(p_r_object_id, p_platform_name,p_exported_file_path, p_is_binary, p_extraction_status, p_extraction_error, p_extraction_datetime); 

    END;
    END IF;




    IF(p_utility_name ='PRE-TRANSFORMATION')
    THEN
    BEGIN
    OPEN p_refcur FOR
    SELECT exported_file_path,component_tcm_id FROM utilities_log
    WHERE platform_name= p_platform_name
    AND loading_status=p_loading_status
    AND extraction_status=p_extraction_status
    AND Is_binary=p_Is_binary; 


    END;
    END IF;

1 个答案:

答案 0 :(得分:1)

假设您正在使用默认事务隔离级别(读取已提交),将从游标中获取的数据是从光标打开时开始的数据的一致视图。当您的应用程序将来从游标中获取数据时,将不会返回对光标打开后提交的表的更改。如果要获取当前数据,则需要关闭并重新打开光标。