• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

PL/SQL Primary key connects to multiple columns

 
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
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?
 
Dave Tolls
Master 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
 
The glass is neither half full or half empty. It is too big. But this tiny ad is just right:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic