Oracle
 sql >> база данни >  >> RDS >> Oracle

непоследователни типове данни:при връщане на таблица от курсора в пакетна функция - ORACLE

Опитайте това:

        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;

АКТУАЛИЗИРАН КОД:

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. Database
  2.   
  3. Mysql
  4.   
  5. Oracle
  6.   
  7. Sqlserver
  8.   
  9. PostgreSQL
  10.   
  11. Access
  12.   
  13. SQLite
  14.   
  15. MariaDB
  1. Каква е настройката за преглед на частта от часа с дата в разработчика на Oracle PL/SQL?

  2. Oracle Forms в R12/R12.2

  3. Oracle-Преобразуване на SQL в ANSI SQL

  4. списък, разделен със запетая

  5. Oracle Data Mining (ODM) – Инсталиране и настройка