Quick Search:
 
 Oracle PL/SQL: INSERT FIRST WHEN Jump to:  
Category: >> Oracle PL/SQL >> INSERT FIRST WHEN  

<< lastnext >>

Snippet Name: INSERT FIRST WHEN

Description: The WHEN clause is evaluated in the order in which it appears in the statement.

For the first WHEN clause that evaluates to true, the database executes the corresponding INTO clause and then skips subsequent WHEN clauses for the given row.

This example uses the FIRST clause to put orders greater than 2,900,000 into the special_orders table and exclude those orders from the large_orders table.

Also see:
» INSERT With Returning Clause
» Create Table INSERT (CTAS)
» Inserting into SELECT statement
» INSERT WITH CHECK OPTION
» INSERT ALL WHEN
» INSERT ALL
» INSERT WHEN
» INSERT: Using A Record
» INSERT with Select
» INSERT: Multiple Column Table Or View ...
» INSERT: Multiple Column Table Or View ...
» INSERT: Single Column Table Or View
» FORALL Insert
» INSERT

Comment: (none)

Language: PL/SQL
Highlight Mode: PLSQL
Last Modified: March 04th, 2009

INSERT FIRST
INTO <table_name> VALUES <column_name_list)
INTO <table_name> VALUES <column_name_list)
...
<SELECT Statement>;
 
 
INSERT FIRST
   WHEN ottl < 100000 THEN
      INTO small_orders
         VALUES(oid, ottl, sid, cid)
   WHEN ottl > 100000 AND ottl < 200000 THEN
      INTO medium_orders
         VALUES(oid, ottl, sid, cid)
   WHEN ottl > 290000 THEN
      INTO special_orders
   WHEN ottl > 200000 THEN
      INTO large_orders
         VALUES(oid, ottl, sid, cid)
   SELECT o.order_id oid, o.customer_id cid, o.order_total ottl,
      o.sales_rep_id sid, c.credit_limit cl, c.cust_email cem
      FROM orders o, customers c
      WHERE o.customer_id = c.customer_id;
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org