Aquarius24
Aquarius24

Reputation: 1866

How to get cursor in stored procedure updated?

I have a stored procedure in oracle which is using cursor.Its fetching the data properly when i am calling it through C# code.However if table gets updated then also i am getting old values after running code in my C# application. I need to compile each time the procedure to get the updated values... Any idea?

PFB snippet of my stored procedure...

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;

Upvotes: 0

Views: 316

Answers (1)

Justin Cave
Justin Cave

Reputation: 231661

Assuming you are using the default transaction isolation level (read committed), the data that will be fetched from the cursor is a consistent view of the data as of the moment the cursor is opened. Changes to the table that are committed after the cursor is opened will not be returned when your application fetches data from the cursor in the future. If you want to get the current data, you would need to close and re-open the cursor.

Upvotes: 1

Related Questions