sql >> Database teknologi >  >> RDS >> Oracle

inkonsistente datatyper:når tabel returneres fra markøren i en pakkefunktion - ORACLE

Prøv dette:

        out_rec cst_record;

        CURSOR C1 IS
        SELECT ...;

  BEGIN

    open c1;
    LOOP
    FETCH c1 INTO out_rec;

  exit when c1%notfound;

    PIPE ROW(out_rec);

  END LOOP;

  close c1;

  RETURN;

END fnc_get_contractor_id;

OPDATERET KODE:

CREATE OR REPLACE PACKAGE pkg_contrator_of_consultant AS

    TYPE cst_record IS RECORD(
       consultant_id NUMBER(10));

    TYPE cst_id_type IS TABLE OF cst_record;

    FUNCTION fnc_get_contractor_id(cst_username IN VARCHAR2)
        RETURN cst_id_type
        PIPELINED;
END;
/

CREATE OR REPLACE PACKAGE BODY pkg_contrator_of_consultant AS 
FUNCTION fnc_get_contractor_id(cst_username IN VARCHAR2 )
    RETURN cst_id_type
    PIPELINED IS    

    CURSOR c1 IS
    SELECT plc.FK2_CONTRACTOR_ID
        FROM lds_consultant cons
        INNER JOIN lds_account acc on cons.consultant_id = acc.fk1_consultant_id 
        INNER JOIN lds_placement plc on acc.account_id = plc.FK1_ACCOUNT_ID
        WHERE UPPER(cons.USERNAME) = UPPER(cst_username)
        AND UPPER(plc.PLT_TO_PERMANENT) = UPPER('Y');

        out_rec cst_record;
    BEGIN

        open c1;
        LOOP
        FETCH c1 INTO out_rec;

      exit when c1%notfound;

        PIPE ROW(out_rec);

      END LOOP;

      close c1;

      RETURN;

    END fnc_get_contractor_id;
END;
/



  1. Bedste måde at ringe til en webtjeneste fra TSQL

  2. Sequelize Eager Loading Error, når der inkluderes relateret model

  3. [Video] Introduktion til JSON-datatyper i PostgreSQL

  4. Gruppering af poster time for time eller dag for dag og udfylde huller med nul eller null i mysql