Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to insert only selected fields into the table by using Insert query?

723451Sep 21 2009 — edited Sep 22 2009
Hi:

I am getting the problem at the time insertion. There are two tables and i want to fetch some record from one table and insert it into another table, but because of some constraints on field i am unable to do this. My first table is COM_Bank Master and it is in krantidb database:

BANK_ID NUMBER(10,0)
NAME_EN VARCHAR2(60 BYTE)
CREATED_BY NUMBER(20,0)
DATE_CREATED DATE
MODIFIED_BY NUMBER(20,0)



And second table is C_Bank and it is in crayom_db database:

C_BANK_ID NUMBER(10,0)
AD_CLIENT_ID NUMBER(10,0)
AD_ORG_ID NUMBER(10,0)
ISACTIVE CHAR(1 BYTE)
CREATED DATE
CREATEDBY NUMBER(10,0)
UPDATED DATE
UPDATEDBY NUMBER(10,0)
NAME NVARCHAR2(60 CHAR)
ROUTINGNO NVARCHAR2(20 CHAR)
C_LOCATION_ID NUMBER(10,0)
SWIFTCODE NVARCHAR2(20 CHAR)
ISOWNBANK CHAR(1 BYTE)
DESCRIPTION NVARCHAR2(255 CHAR)


And i have write the following script:

DECLARE
CURSOR comp_cur IS select bank_id,date_created,created_by,modified_by,name_en from COM_BANK_MASTER ;
comp_rec comp_cur%ROWTYPE;
BEGIN
OPEN comp_cur;
FETCH comp_cur INTO comp_rec;

WHILE comp_cur%FOUND
LOOP
dbms_output.put_line(comp_rec.bank_id);
insert into crayom_db.C_Bank values(comp_rec.bank_id,0,0,'Y',comp_rec.date_created,comp_rec.created_by,sysdate,0,comp_rec.name_en,'A',0,'','','');
FETCH comp_cur INTO comp_rec;
End LOOP;
close comp_cur;
END;


But i am getting the null constraints and violate the constraint error.


Can any body help me?

Thank You.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 20 2009
Added on Sep 21 2009
17 comments
2,827 views