top of page

BULK COLLECT using TYPE Record

Writer's picture: Rumesh Aponso (RMAX)Rumesh Aponso (RMAX)
DECLARE
   sql_stmt_   VARCHAR2(32000);
  
   CURSOR get_data IS
      SELECT t.order_no,
             t.line_no,
             t.rel_no,
             t.line_item_no,
             t.customer_no,
             t.catalog_no
      FROM   customer_order_line_tab t
      WHERE  ROWNUM <= 10;
  
   -- create type using a cursor
   TYPE temp_rec_type IS TABLE OF get_data%ROWTYPE INDEX BY BINARY_INTEGER;
   temp_rec_   temp_rec_type;
BEGIN
   -- Way 1 - Load data using normal cursor open fecth
   --OPEN  get_data;
   --FETCH get_data BULK COLLECT INTO temp_rec_;
   --CLOSE get_data;
  
   -- Way 2 - Load data using executing sql statement via EXECUTE IMMEDIATE
   sql_stmt_ := 'SELECT t.order_no,
                        t.line_no,
                        t.rel_no,
                        t.line_item_no,
                        t.customer_no,
                        t.catalog_no
                 FROM   customer_order_line_tab t
                 WHERE  ROWNUM <= 10';
  
   EXECUTE IMMEDIATE sql_stmt_ BULK COLLECT INTO temp_rec_;
  
   -- loop of fetch data
   FOR i_ IN 1..temp_rec_.COUNT LOOP
      Dbms_Output.Put_Line(temp_rec_(i_).order_no     || ';' ||
                           temp_rec_(i_).line_no      || ';' ||
                           temp_rec_(i_).rel_no       || ';' ||
                           temp_rec_(i_).line_item_no || ';' ||
                           temp_rec_(i_).customer_no  || ';' ||
                           temp_rec_(i_).catalog_no);
   END LOOP;
END;

10 views0 comments

Related Posts

See All

Fnd Dynamic Tab Page in IEE Client

[FndWindowRegistration("YVVDA_COMPANY_ADDR", "YvvdaCompanyAddr", FndWindowRegistrationFlags.HomePage)] [FndDynamicTabPage("frmCompanyAddr...

LISTAGG in PLSQL

Example 1: SELECT DISTINCT LISTAGG(t.commission_receiver, ';') WITHIN GROUP (ORDER BY t.commission_receiver) FROM...

Get Foundation Error from ORA Error

FUNCTION Strip_Ora_Error ( sqlerrm_        IN VARCHAR2,    sqlcode_        IN NUMBER DEFAULT NULL,    strip_ora_only_ IN BOOLEAN DEFAULT...

Comments


Copyright © 2025 RMAXOneNote

  • Online CV
  • LinkedIn
  • Youtube
  • GitHub
  • Blogger
bottom of page