Home » SQL & PL/SQL » SQL & PL/SQL » unable to insert column from other table
unable to insert column from other table [message #196556] Thu, 05 October 2006 21:48 Go to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
sir,
i unable to insert the column from other table.
what are the following steps to insert column.
Razz

SQL>SELECT * FROM CLIENT_MASTER;

CLIENT NAME STATE BAL_DUE
------ ---------------- ------ ----------
C00001 Ivan Bayross Maharastra 15000
C00002 Vandana Saitwal Tamil Nadu 0
C00003 Paramada Jaguste Maharastra 5000
C00004 Basu Navindgi Maharastra 0
C00005 Ravi Sreedharan delhi 2000
C00006 Rukmini Maharastra 0

SQL>SELECT * FROM RAJ;

CLIENT NAME STATE BAL_DUE
------ ---------------- ------ ----------
C00001 Ivan Bayross Maharastra
C00002 Vandana Saitwal Tamil Nadu
C00003 Paramada Jaguste Maharastra
C00004 Basu Navindgi Maharastra
C00005 Ravi Sreedharan delhi
C00006 Rukmini Maharastra

SQL>
1* INSERT INTO RAJ SELECT BAL_DUE FROM CLIENT_MASTER
INSERT INTO RAJ SELECT BAL_DUE FROM CLIENT_MASTER
*
ERROR at line 1:
ORA-00947: not enough values

[Updated on: Thu, 05 October 2006 22:06]

Report message to a moderator

Re: unable to insert column from other table [message #196563 is a reply to message #196556] Thu, 05 October 2006 23:40 Go to previous messageGo to next message
rameshuddaraju
Messages: 69
Registered: June 2005
Location: India
Member

Hello Ashish,

Insert always creates a new row in the table.
You are training to insert one column value into a table without specifying the column into which you want to insert.

You have to execute as follows
INSERT INTO RAJ(BAL_DUE)
SELECT BAL_DUE FROM CLIENT_MASTER
but, it creates new rows


Actually your requirement is you have to update your bal_due column

So, try hte following statement.

update raj r set BAL_DUE = (select BAL_DUE from CLIENT_MASTER where CLIENT = r.CLIENT)

with rgds,
Ramesh

Re: unable to insert column from other table [message #196660 is a reply to message #196563] Fri, 06 October 2006 07:31 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
sir i want to copy (bal_due) from table client_master to table raj.
is there's any procedure .
thanx
Re: unable to insert column from other table [message #196664 is a reply to message #196660] Fri, 06 October 2006 07:43 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
And when you tried the previous posters suggestion of
update raj r set BAL_DUE = (select BAL_DUE from CLIENT_MASTER where CLIENT = r.CLIENT) 
, did it do what you wanted? If not, what errors did you encounter?
Re: unable to insert column from other table [message #196666 is a reply to message #196664] Fri, 06 October 2006 07:55 Go to previous messageGo to next message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
i know i can do it by update clause.
i have to update each & every row one by one, which is the last option.since i want true copy(bal_due) of it on table raj from table(client_master)without updating.is there any procedure
Re: unable to insert column from other table [message #196669 is a reply to message #196666] Fri, 06 October 2006 08:04 Go to previous messageGo to next message
joy_division
Messages: 4642
Registered: February 2005
Location: East Coast USA
Senior Member
Ramesh has already given you the answer.
Re: unable to insert column from other table [message #196671 is a reply to message #196669] Fri, 06 October 2006 08:07 Go to previous message
ashish_pass1
Messages: 114
Registered: August 2006
Location: delhi
Senior Member
ok thanx a lot..
Previous Topic: Help checking constraints
Next Topic: unable to view constraints
Goto Forum:
  


Current Time: Wed Dec 07 16:53:16 CST 2016

Total time taken to generate the page: 0.07552 seconds