Wednesday, February 8, 2017

When do INSERT Statements Fail

Some of the most common errors which occur while executing INSERT statement:

  • There is a mismatch between the number of columns and the number of values
  • If the datatype of an inserted value is a mismatch with the column of the target table
  • There is a size mismatch between a value and its target column.
  • When a column is defines as not NULL and the insertion value is NULL.

--------Here we have discussed three different methods to insert multiple values into a single table.

Method 1:  Traditional INSERT…VALUE Method
Syntax:
INSERT INTO <table_name> ( Column1, Column2 )
VALUES ( Value1, Value2 ), ( Value3, Value4 )
Method 2: INSERT with SELECT
Syntax:
INSERT INTO <table_name> ( Column1, Column2 )
SELECT expression1, expression2, …
Method 3: INSERT with SELECT UNION ALL 
Syntax:
INSERT INTO <table_name>  (column1, column2)
SELECT  ‘First’ ,1
UNION ALL
SELECT  ‘Second’ ,2
UNION ALL
SELECT  ‘Third’ ,3
 Add a WHEN-WINDOW-CLOSED trigger with the following code:
IF ( Get_Window_Property('SELECTED', VISIBLE) = 'TRUE' ) THEN
            Hide_Window('SELECTED');
            Go_Block('EMPLOYEES');
ELSE
            Exit_Form;
END IF;

No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...