Use subquery in pl/sql block : Select Into « PL SQL « Oracle PL / SQL






Use subquery in pl/sql block

    

SQL> create table myTable
  2  as
  3  select rownum id, a.*
  4    from all_objects a
  5   where 1=0
  6  /
SQL>
SQL> create or replace procedure dw_style
  2  as
  3      i number;
  4  begin
  5      select count(*) into i
  6        from (
  7      select
  8             t1.data_object_id, myTable2.data_object_id
  9        from myTable t1, myTable myTable2
 10       where t1.id = myTable2.id
 11             );
 12  end;
 13  /
SQL>
SQL> drop table myTable;

   
    
    
    
  








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.This script demonstrates how to do a non-bulk select into elements of a PL/SQL table.
19.TOO_MANY_ROWS exception and select into command
20.Store max(salary) to a variable
21.Store max(tableName.column) to tableName.column.type variable
22.Bulk Collection: fetch a single row from the ALL_OBJECTS table.
23.Calculate salary by adding salary with max(salary)
24.Select data for update
25.Select value from aggregate function to variable