Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Having identity crisis!
Message
From
30/09/1999 07:24:19
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
30/09/1999 06:56:34
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00270941
Message ID:
00270953
Views:
32
>Hi All!
>
>Thought I'd float this again as I didn't get any response yesterday.
>
>In an application, I have a SQL Server table which has an autoincrement identity column. When I create a new record in it, I also want to create a number of records in a child table using the parent's id column content as the relating column.
>
>The problem is that, when I insert the record, do the tableupdate, and requery the remote view, it doesn't always return with the correct id column from the newly created parent table record. I usually get a few child records with one id number, a few more with another, and so on...., usually ending up with only three or four numbers in the child table where there should be twenty plus (the number of records in the parent table, if this is the first iteration of the procedure).
>
>Any ideas on how to assure that I see the correct new SQL identity column entry for a freshly inserted record in the parent table?
>
>TIA!
>Tom.


Tom,
Unfortunately I don't have SQL server installed to test. I would something like this :
*method newparent
lparameters tcParent, tcChild, tcFieldList, tcValues, tcIdField
begin transaction
insert into (tcParent) (&tcFieldList) values (&tcVAlues)
if tableupdate(0,.f.,tcParent)
   insert into (tcChild) (&tcIdField) values (eval(tcParent+"."+tcIdField))
   if tableupdate(0,.f.,tcChild)
     end transaction
   else
     rollback
     return .f.
   endif
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform