• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

PL/SQL Primary key connects to multiple columns

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So my code should copy a few columns from two tables and insert them into a new another one but when i check the table afterwards it returns the primary key with alot of other columns. The primary key is a car plate number so it should be unique. Pnr is also a primary key but i think i didnt see any multiplied ones. This is my code:

declare
cursor c_fartdårar is select b.pnr,b.fnamn,b.enamn,f.regnr,f.tillverkare,f.modell
from bilägare b,fordon f
where f.pnr = b.pnr  
and f.hk > 200;

begin
for v_rec in c_fartdårar  

loop
insert into fartdåre(pnr,fnamn,enamn,regnr,tillverkare,modell)
values(v_rec.pnr,v_rec.fnamn,v_rec.enamn,v_rec.regnr,v_rec.tillverkare,v_rec.modell);
end loop;  
commit;
dbms_output.put_line('Kopieringen klar!');
end;

Anybody got an idea?
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, you are inserting multiple columns, at least from your INSERT statement above.

I'm really not sure what the issue is.

Can you show us some example data, and then what you are seeing in the table that is confusing you?
 
Hugo Nilsson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! There was nothing wrong actually. The was some other code that "interfered" so it worked when i ran it by itself
 
Ever since I found this suit I've felt strange new needs. And a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic