Question : Return Ref

I have following cursor which accepts the partition name as input parameter.
I want return the values as refcursor and want to lock those records which are selected.

Can I get some help how to perform this process using PLSQL.

I have written sample SP which just provides out lines. Can I get some help to rewrite this SP to work.

Thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
CREATE OR REPLACE PROCEDURE C_PUT
(p_partition_name in varchar2,
 p_dat_no number
 r_ref out sys_refcursor)
CURSOR CUR IS 
'SELECT PAT_NO, PNAME, OT_P
 FORM TARGET.PATENTS partition ('||p_partition_name||')
 WHERE DAT_NO = p_dat_no
 ORDER BY PAT_NO
 FOR UPDATE SKIP LOCKER;'
 
BEGIN

IF CUR%ROWCOUNT > 0 THEN
DBMS_OUTPUT.PUT_LINE('There are rows to process');
RETURN as Refcursor
Else
DBMS_OUTPUT.PUT_LINE('NO rows to process');
END IF;

END;

Answer : Return Ref

What about this. You can update the table without changing anything.

CREATE OR REPLACE PROCEDURE C_PUT
(p_partition_name in varchar2,
 p_dat_no number
 r_ref out sys_refcursor)
 CURSOR CUR IS
 SELECT PAT_NO, PNAME, OT_P
 FORM TARGET.PATENTS partition ('||p_partition_name||')
 WHERE DAT_NO = p_dat_no
 ORDER BY PAT_NO;
 
BEGIN
----- modification
  update TARGET.PATENTS partition ('||p_partition_name||')
  set PAT_NO = PAT_NO
  WHERE DAT_NO = p_dat_no;
 
  IF CUR%ROWCOUNT > 0 THEN
    DBMS_OUTPUT.PUT_LINE('There are rows to process');
    RETURN as Refcursor
  Else
    DBMS_OUTPUT.PUT_LINE('NO rows to process');
  END IF;

END;
Random Solutions  
 
programming4us programming4us