Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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
 
I'd appreciate it if you pronounced my name correctly. Pinhead, with a silent "H". Petite ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic