DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: ORACLE - Como Hacer un cursor referenciando a otros cursores

  1. #1
    Join Date
    Nov 2000
    Posts
    3

    Question

    Por favor necesito hacer un cursor en ORACLE pero que referencie a otros cursores.


    Lo he intentado declarando el primer cursor , luego declarando el segundo cursor, y luego el tercer cursor que hace el select a los dos primeros cursores, pero al momento de correr el archivo .sql me sale error como si no reconociera los cursores que referencio.

    /*
    Este codigo declara 2 cursores luego los abre y despues abre un tercer cursor con los
    datos del primer y segundo cursor.
    */

    DECLARE

    V_COD S_ASSET.OWNER_ACCNT_ID%TYPE;
    V_APE S_ORG_EXT.NAME%TYPE;
    V_DOC S_ORG_EXT.LOC%TYPE;
    V_EMP S_ORG_EXT.BU_ID%TYPE;
    V_CONT1 NUMBER := 0;
    V_CONT2 NUMBER := 0;

    TYPE t_resulrecord IS RECORD (
    XID S_ASSET.OWNER_ACCNT_ID%TYPE,
    APE S_ORG_EXT.NAME%TYPE,
    DOC S_ORG_EXT.LOC%TYPE,
    EMP S_ORG_EXT.BU_ID%TYPE,
    CO1 NUMBER,
    CO2 NUMBER
    );

    TYPE t_resulcursor IS REF CURSOR RETURN t_resulrecord ;

    v_cursor_resul t_resulcursor;

    CURSOR C_1 IS
    SELECT A.OWNER_ACCNT_ID,
    COUNT(A.ASSET_COND_CD) CONT1,
    B.NAME APELLIDO1,
    B.LOC DOCUMENTO1,
    B.BU_ID EMPRESA1
    FROM S_ASSET A,
    S_ORG_EXT B
    WHERE A.OWNER_ACCNT_ID = B.ROW_ID AND
    UPPER(TRIM(A.ASSET_COND_CD)) = 'NO CUALIFICADO'
    GROUP BY A.OWNER_ACCNT_ID,
    B.NAME,
    B.LOC,
    B.BU_ID;

    CURSOR C_2 IS
    SELECT OWNER_ACCNT_ID,
    COUNT(ASSET_COND_CD) CONT2
    FROM S_ASSET
    GROUP BY OWNER_ACCNT_ID;

    BEGIN
    SET TRANSACTION USE ROLLBACK SEGMENT RBS_SIEBEL;
    OPEN C_1;
    OPEN C_2;

    OPEN v_cursor_resul FOR
    SELECT C_1.OWNER_ACCNT_ID CODIGO,
    C_1.APELLIDO1 APELLIDO,
    C_1.DOCUMENTO1 DOCUMENTO,
    C_1.EMPRESA1 EMPRESA,
    C_1.CONT1,
    C_2.CONT2
    FROM C_1,
    C_2
    WHERE C_1.OWNER_ACCNT_ID = C_2.OWNER_ACCNT_ID AND
    C_1.CONT1 = C_2.CONT2;

    LOOP
    FETCH v_cursor_resul INTO V_COD,V_APE,V_DOC,V_EMP,V_CONT1,V_CONT2 ;
    EXIT WHEN v_cursor_resul%NOTFOUND;


    --UPDATE EIM_ACCOUNT
    -- SET DIVN_CD = 'NO CUALIFICADO'
    -- WHERE NAME = V_APE AND
    -- LOC = V_DOC AND
    -- ACCNT_BU = V_EMP;
    END LOOP;
    COMMIT;
    CLOSE v_cursor_resul;
    CLOSE C_2;
    CLOSE C_1;
    END;
    /

    FROM C_1,
    *
    ERROR en lÃ*nea 57:
    ORA-06550: lÃ*nea 57, columna 9:
    PLS-00201: el identificador 'C_1' debe declararse
    ORA-06550: lÃ*nea 51, columna 2:
    PL/SQL: SQL Statement ignored
    ORA-06550: lÃ*nea 50, columna 7:
    PLS-00320: la declaración del tipo de expresión es incompleta o con forma inadecuada
    ORA-06550: lÃ*nea 50, columna 2:
    PL/SQL: SQL Statement ignored

    [Edited by cvasquez on 11-22-2000 at 06:01 AM]
    Muchas Gracias...

  2. #2
    Join Date
    Oct 2000
    Location
    Cambridge, MA (Boston)
    Posts
    144
    ?Puedes mostrar una porción de secuencias de órdenes? No estoy segura lo que estás intentando hacer. Incluye tu mensaje de error también por favor. Espero que entiendas mi español.

    Gracias, D.

    [Edited by DBAtrix on 11-21-2000 at 09:53 PM]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width