Home » SQL & PL/SQL » SQL & PL/SQL » Help - Sql statement
Help - Sql statement [message #18530] Mon, 04 February 2002 11:30 Go to next message
Joan
Messages: 36
Registered: February 2002
Member
insert into tableA a
( ACCESS_UNRESTRICTED_SW
,PARENT_ACCESS_ID
,GLOBAL_travel_ID) values
(select ACCESS_UNRESTRICTED_SW
,PARENT_ACCESS_ID
,GLOBAL_travle_ID
from tableA b
where user_id=upper('&1')
and a.access_id =b.access_id)
where user_id=upper('&2')
/
I need to copy the access of user 1 to user 2 at the same table
Re: Help - Sql statement [message #18543 is a reply to message #18530] Tue, 05 February 2002 02:03 Go to previous messageGo to next message
Geoffrey
Messages: 32
Registered: February 2002
Member
I think you can do it like this

if the table exists :

insert into user1.table
(select * from user2.table);

or if the table doen not exist :

create user2.table as select * from user1.table;
Re: Help - Sql statement [message #18549 is a reply to message #18530] Tue, 05 February 2002 04:51 Go to previous messageGo to next message
Joan
Messages: 36
Registered: February 2002
Member
insert into member_parent_user_security where
I am still get errors values missing even after using select *... please help
user_id =upper('&1')
( select * from member_access_parent_user_security where user_id = upper('&2') )
/
~

insert into member_parent_user_security where user_id =upper('u215310z')
*
ERROR at line 1:
ORA-00926: missing VALUES keyword
Re: Help - Sql statement [message #18576 is a reply to message #18530] Tue, 05 February 2002 22:49 Go to previous message
Geoffrey
Messages: 32
Registered: February 2002
Member
if userb exists in the table you can't do an insert but you will have to do an update or you will have to delete userb, do an insert and update the username to userb (if you have a lot of columns that is the fastest way)

delete from table member_parent_user_security where user_id = upper('&2') ;

insert into member_parent_user_security (select * from member_parent_user_security where user_id = upper('&1')) ;

update member_parent_user_security
set user_id = upper('&2')
where user_id = upper('&1') and
rownum = (
select max(rownum) from member_parent_user_security
where user_id = upper('&1') );

commit;
Previous Topic: CHAR DATATYPE: FIXED?
Next Topic: help me!!
Goto Forum:
  


Current Time: Mon Sep 27 06:07:53 CDT 2021