[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] SQL kopiering af records i samme tabel



Hej Rasmus,

On Thu, 14 Apr 2005 11:04:56 +0200, Rasmus Wätjen wrote:
> Nu er det sådan at jeg gerne vil kunne kopiere en post i tabel A til en 
> ny. Det betyder at alle n tilknyttede records i tabel B også skal 
> kopieres og have en opdateret fremmednøgle.
>
> Er der nogen smart måde at gøre det på, eller skal man lave et
> udtræk, rette i fremmednøgle-kolonnen og inserte påny?

Der er så vidt jeg ved ikke nogen smart måde - i hvertfald ikke i min
tolkning af din anvendelse af "smart". Problemet er så vidt jeg kan se,
at du ikke blot kan indsætte kopierede rækker i B, hvor kun
fremmednøgleværdien er ændret - for B's primærnøgle er antagelig
andet eller mere end fremmednøglen.

Jeg ville starte en transaktion, insert'e i A, insert'e i B, og commit'e.
Du kan evt. tage temporære tabeller og/eller user defined functions i
anvendelse, hvis det synes hensigtsmæssigt i dit setup.

-- 
Greetings from Troels Arvin, Copenhagen, Denmark



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:44 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *