An anonymous block program to write the record to a row : Data Insert « PL SQL « Oracle PL / SQL






An anonymous block program to write the record to a row

    

SQL>
SQL> CREATE TABLE emp
  2   (emp_id              INTEGER             NOT NULL
  3   ,fname               VARCHAR2(30 CHAR)   NOT NULL
  4   ,mid_name           VARCHAR2(1 CHAR)
  5   ,lname                VARCHAR2(30 CHAR)   NOT NULL
  6   ,CONSTRAINT emp_pk PRIMARY KEY (emp_id));

Table created.

SQL>
SQL>
SQL> 
SQL> DECLARE
  2
  3     
  4     emp1 emp%ROWTYPE;
  5
  6   BEGIN
  7
  8     
  9     emp1.emp_id := 1;
 10     emp1.fname := 'John';
 11     emp1.mid_name := 'D';
 12     emp1.lname := 'R';
 13
 14     
 15     INSERT INTO emp VALUES (emp1.emp_id ,emp1.fname ,emp1.mid_name,emp1.lname);
 16
 17     
 18     COMMIT;
 19
 20   END;
 21   /

PL/SQL procedure successfully completed.

SQL>
SQL>
SQL>
SQL> drop table emp;

Table dropped.

SQL>

   
    
    
    
  








Related examples in the same category

1.Use in parameter to pass value and insert value to a table
2.Data insert in a procedure
3.Insert data in procedure
4.Insert value passed in by parameter to a table
5.Insert value to a table after calculation
6.Insert value to product and productcategory with stored procedure
7.Insert value to table with for loop
8.Insert a specified number of suppliers and products per supplier
9.Insert 100000 rows into a table with for loop
10.Loop through all to do a bulk insert
11.This script demonstrates returning clause
12.Bulk insert with insert ... select
13.Hard code value and insert