Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 3 of 3 total |
Union of smaller table |
Wed, Sep 17 2008 10:57 AM | Permanent Link |
"C.M." | Hi
I have two table. Table A: many fields (F1, F2, F3, F4, F5, F6,F7 ..... and so on) and is empty Table B: only 3 fields F1, F2 and F3 full of data ! I need to "append" the data of table B on table A using NULL for the non existents fields. The structure of table B is variable Thanks, and sorry for my english ! C.M. |
Wed, Sep 17 2008 12:31 PM | Permanent Link |
"Robert" | "C.M." <c.m.@senzaemail.com> wrote in message news:D10BC071-726A-4E0A-958B-3F0977B582B2@news.elevatesoft.com... > Hi > I have two table. > Table A: many fields (F1, F2, F3, F4, F5, F6,F7 ..... and so on) and is > empty > Table B: only 3 fields F1, F2 and F3 full of data ! > > I need to "append" the data of table B on table A using NULL for the non > existents fields. > > The structure of table B is variable > INSERT INTO A (F1, F2, F3) SELECT F1, F2, F3 FROM B But that business about the structure of B being variable makes me think that you need something else. You might have to build the SQL similar to the one above, but using B's field names. var s : string; j : integer; begin s := ''; B.Open; for j := 0 to B.FieldDefs.Count - 1 do begin if s = '' then s := B.FieldDefs[j].Name else s := s + ', ' + B.FieldDefs[j].Name; end; and stick S into the two places above where you see F1, F2, F3 Robert |
Thu, Sep 18 2008 6:17 AM | Permanent Link |
"C.M." | "Robert" <ngsemail2005withoutthis@yahoo.com.ar> ha scritto nel messaggio news:BB953C96-90B8-4D3F-8BFF-2FB0E5A8F980@news.elevatesoft.com... > > "C.M." <c.m.@senzaemail.com> wrote in message > news:D10BC071-726A-4E0A-958B-3F0977B582B2@news.elevatesoft.com... >> Hi >> I have two table. >> Table A: many fields (F1, F2, F3, F4, F5, F6,F7 ..... and so on) and is >> empty >> Table B: only 3 fields F1, F2 and F3 full of data ! >> >> I need to "append" the data of table B on table A using NULL for the non >> existents fields. >> >> The structure of table B is variable >> > > INSERT INTO A (F1, F2, F3) SELECT F1, F2, F3 FROM B > > But that business about the structure of B being variable makes me think > that you need something else. You might have to build the SQL similar to > the one above, but using B's field names. > > var s : string; > j : integer; > begin > s := ''; > B.Open; > > for j := 0 to B.FieldDefs.Count - 1 do begin > if s = '' then s := B.FieldDefs[j].Name > else s := s + ', ' + B.FieldDefs[j].Name; > end; > > and stick S into the two places above where you see F1, F2, F3 > > Robert > > > Thank you Robert very helpful example ! C. |
This web page was last updated on Saturday, April 27, 2024 at 08:52 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |