Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Inserting a Record into a Table

RE: Inserting a Record into a Table

From: Jamadagni, Rajendra <Rajendra.Jamadagni_at_espn.com>
Date: Fri, 03 Aug 2001 10:56:09 -0700
Message-ID: <F001.0035F759.20010803075327@fatcity.com>

If you are (or will be) using 9i,

straight from the manual ....

<manual>
Inserting Records into the Database
A new PL/SQL-only extension of the INSERT statement lets you insert records into database rows using a single variable of type RECORD or %ROWTYPE instead of a list of fields. That makes your code more readable and maintainable. The record type cannot be nested. Also, the number of fields in the record must equal the number of columns listed in the INTO clause, and corresponding fields and columns must have compatible datatypes. An example follows:

DECLARE
   TYPE EmpRec IS RECORD (

      emp_id    NUMBER(4),
      job_title VARCHAR2(9),
      salary    NUMBER(7,2));

   emp_info EmpRec;
BEGIN
   emp_info.emp_id := 7975;
   emp_info.job_title := 'CLERK';
   emp_info.salary := 1500;

   INSERT INTO emp (empno, job, sal) VALUES (emp_info); END; In the example below, you use a %ROWTYPE record. A column list is not needed because the record contains a field for each column in the database table.

DECLARE
   dept_info dept%ROWTYPE;
BEGIN

   dept_info.dept_num := 70;
   dept_info.dept_name := 'PERSONNEL';
   dept_info.location := 'DALLAS';

   INSERT INTO dept VALUES (dept_info);
END; </manual>

HTH
Raj



Rajendra Jamadagni MIS, ESPN Inc. Rajendra dot Jamadagni at ESPN dot com
Any opinion expressed here is personal and doesn't reflect that of ESPN Inc.

QOTD: Any clod can have facts, but having an opinion is an art !

*********************************************************************2

This e-mail message is confidential, intended only for the named recipient(s) above and may contain information that is privileged, attorney work product or exempt from disclosure under applicable law. If you have received this message in error, or are not the named recipient(s), please immediately notify corporate MIS at (860) 766-2000 and delete this e-mail message from your computer, Thank you.

*********************************************************************2

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Jamadagni, Rajendra
  INET: Rajendra.Jamadagni_at_espn.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Fri Aug 03 2001 - 12:56:09 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US