Home » SQL & PL/SQL » SQL & PL/SQL » Insert Statement ?
Insert Statement ? [message #1628] Thu, 16 May 2002 12:09 Go to next message
Dharan Sakthi
Messages: 3
Registered: May 2002
Junior Member
I want to do an insert. The following sql does not work
but that is what I have in mind. Any suggestions

Insert into emp(idname, idage)
values
(select id from nametable where name = 'jack';,
select id from agetable where age = 24;);
Re: Insert Statement ? [message #1629 is a reply to message #1628] Thu, 16 May 2002 12:13 Go to previous messageGo to next message
ks
Messages: 12
Registered: January 2002
Junior Member
Try it this way:

Insert into emp(idname, idage)
values
((select id from nametable where name = 'jack'),
(select id from agetable where age = 24))
Re: Insert Statement ? [message #1631 is a reply to message #1628] Thu, 16 May 2002 12:23 Go to previous messageGo to next message
Dharan
Messages: 1
Registered: May 2002
Junior Member
I did not explain my ? properly. The select statment's will be receving their inputs from a cursor. Sorry about that.

Insert into emp(idname, idage)
values
(select id from nametable where name = cur.name;,
select id from agetable where age = cur.age;);
Re: Insert Statement ? [message #1634 is a reply to message #1628] Thu, 16 May 2002 17:18 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
insert into emp (idname, idage)
  select n.id, a.id
    from nametable n, agetable a
   where n.name = cur.name
     and a.age = cur.age;
Previous Topic: Row count for a select for cursor....
Next Topic: Trigger and integrity constraint
Goto Forum:
  


Current Time: Fri May 10 16:41:27 CDT 2024