Bulk Collection: fetch a single row from the ALL_OBJECTS table. : Select Into « PL SQL « Oracle PL / SQL






Bulk Collection: fetch a single row from the ALL_OBJECTS table.

    
SQL>
SQL> declare
  2    x number;
  3  begin
  4    select object_id
  5    into   x
  6    from   all_objects
  7    where  rownum <= 1;
  8  end;
  9  /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL> --Here is the equivalent bulk collection version to get 500 rows in a single call.
SQL>
SQL> declare
  2    type numlist is table of number;
  3    x numlist;
  4  begin
  5    select object_id
  6    bulk collect into x
  7    from   all_objects
  8    where  rownum <= 500;
  9  end;
 10  /

PL/SQL procedure successfully completed.

   
    
    
    
  








Related examples in the same category

1.Select value from table into variable
2.Oracle returns an error when a SELECT statement returns more than one row
3.Catch too_many_rows Exception for 'Select into' statement
4.Multiple-Row SELECT Command with Several Exception-Handling Routines
5.Select count result into a variable
6.Output variable after 'select into'
7.SELECT into value pair
8.Select the number of employees into the l_emp_count variable
9.Select into and subquery
10.Select single value into variable
11.Select two columns into a cursor variable
12.Select value into a number variable in a for loop
13.Select value to variable one by one
14.If no records are retrieved for a SELECT - INTO statement the following error is returned
15.If too many records are returned for a SELECT - INTO statement the following error is returned
16.no_data_found from select ... into
17.select bulk collect into table collection
18.Use subquery in pl/sql block
19.This script demonstrates how to do a non-bulk select into elements of a PL/SQL table.
20.TOO_MANY_ROWS exception and select into command
21.Store max(salary) to a variable
22.Store max(tableName.column) to tableName.column.type variable
23.Calculate salary by adding salary with max(salary)
24.Select data for update
25.Select value from aggregate function to variable