IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
DBA
Search DBA Group:

Advanced
-Collapse +Expand DBA Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyDBA, Databases, & Data BoardInterbase Topic     Print This   

how to manadage that...

how to manadage that... in Interbase topic (part of our DBA, Databases, & Data group).

Quick Search: manadage   how manadage   how manadage that  

os2
i use interbase 6 and delphi

i try to do a location car program

i have a table named Location with field
nolocation
km....

i have another table named vehicule with fied
novehicule
km...

and i have another table location_vehicule who join Location and vehicule with field

nolocation and novehicule

i want to know how to manage a new location...

when i go to this form should I ask a new nolocation to interbase (generator) and after add car to this location or

Inser car to the location, and before post the location ask a nolocation to interbase insert this number in nolocation field of location table and after in nolocation field of location_vehicule

or any other tips to do that?

database diagram



form picture
 Posted 12 years ago (Thread Starter)
Comment Quote
Location=Canada, QuΘbec ,  Joined=12 years ago   MB Posts=2  
More... -Collapse +Expand
os2
 (Inactive)
Canada, QuΘbec
Rank: Cadet 1st Year
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.
Post ID #8391, 5 replies
Thread Started 11/23/2002 6:58:00 PM
View Counter=1488
Last Reply Posted 11/26/2002 7:29:00 AM)

Scott Wehrly
With BEFORE INSERT triggers on both the Location and Vehicule tables, populate the primary key value using Gen_ID calls on the respective generators.



In Delphi, the new primary key values will show up once the newly inserted rows are posted. Those values will then be available for posting a new row in LocationVehicule.



Here's a pseudo-code example in Delphi (which will work if you use the Fields Editor to instantiate TField components for each table):


  tLocation.Insert;

// populate all required fields in tLocation
  tLocation.Post;
  tVehicule.Insert;

// populate all required fields in tVehicule
  tVehicule.Post;
  tLocationVehicule.Insert;
  tLocationVehicule_NoLocation.AsInteger := tLocation_NoLocation.AsInteger;
  tLocationVehicule_NoVehicule.AsInteger := tVehicule_NoVehicule.AsInteger;

// populate the date fields as needed
  tLocationVehicule.Post;



This works with any SQL database, not just InterBase. :)
 Posted 12 years ago
Comment Quote
Location=Las Vegas, NV USA,  Joined=12 years ago   MB Posts=442   KB Posts=19  
More... -Collapse +Expand
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
Rank: Commander
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.
Post ID #8422 (Level 1.1)  Reply to 8391
Thread Started 11/25/2002 11:37:00 AM
View Counter=2
Most Recent Post

Scott Wehrly
That's OK, I still get called Steve from time to time. I'm used to it. Big Grin!



Yes, if the data access was set up using cached updates, then posting an inserted record would not reflect the new ID until you do a full CommitTransaction, and then, only if the TransIsolation level is not tRepeatableRead.



I have used the INSERT trigger/post/fetch new key method successfully in ADO components and SQL Server databases, with InterBase 6 databases and either IBObjects or dbExpress components, and even with Oracle databases and DAO components. As long as the connection and dataset properties are set to do a commit on a post (i.e. not cached updates), this technique works.
 Posted 12 years ago
Comment Quote
Location=Las Vegas, NV USA,  Joined=12 years ago   MB Posts=442   KB Posts=19  
More... -Collapse +Expand
Scott Wehrly
Prestwood IT
 (Inactive)
Las Vegas, NV USA
Rank: Commander
Inactive member.
Member does not subscribe to this thread.
Old Account!
If this is your account, sign in to activate web presence data (sign in quarterly to keep active). Alternatively, you can subscribe to our monthly eMag with a valid email address.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.
Post ID #8443 (Level 1.2)  Reply to 8391
Reply Posted 11/26/2002 7:29:00 AM

Larry Drews
OS2,

Either way would work. The deciding question is: Will you need the Location key for further work? If so, then use the generator technique so that your application can retain the Location key for further work. If you will not need the Location key, then the trigger approach will work just fine.
 Posted 12 years ago
Comment Quote
Location=Iowa ,  Joined=12 years ago   MB Posts=67  
More... -Collapse +Expand
Larry Drews
Iowa
Rank: Cadet 1st Year
Approved member.
Member subscribes to this thread with a verified email.
About Larry Drews
Veteran software developer specializing in Delphi/Kylix development. Currently Manager of Applications Development for a biotech company in Iowa.

Post ID #8397 (Level 1.3)  Reply to 8391
Reply Posted 11/24/2002 11:07:00 AM

Larry Drews
Steve,

Correct me if I am wrong, but doesn't your proposed solution only work if you are using TTables or "live" SQLQueries and also using the BDE? If you are not using the BDE, or if your SQLQueries are not live, but rather "cached updates", then you would need to find another approach. Don't you agree?
 Posted 12 years ago
Comment Quote
Location=Iowa ,  Joined=12 years ago   MB Posts=67  
More... -Collapse +Expand
Larry Drews
Iowa
Rank: Cadet 1st Year
Approved member.
Member subscribes to this thread with a verified email.
About Larry Drews
Veteran software developer specializing in Delphi/Kylix development. Currently Manager of Applications Development for a biotech company in Iowa.

Post ID #8424 (Level 1.4)  Reply to 8391
Reply Posted 11/25/2002 1:41:00 PM

Larry Drews
I'm sorry, I meant Scott! 2 demerits for misusing your name.
 Posted 12 years ago
Comment Quote
Location=Iowa ,  Joined=12 years ago   MB Posts=67  
More... -Collapse +Expand
Larry Drews
Iowa
Rank: Cadet 1st Year
Approved member.
Member subscribes to this thread with a verified email.
About Larry Drews
Veteran software developer specializing in Delphi/Kylix development. Currently Manager of Applications Development for a biotech company in Iowa.

Post ID #8425 (Level 1.5)  Reply to 8391
Reply Posted 11/25/2002 1:42:00 PM

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post:

Enter your name and security key.

Your Name:
Today's security key = P215A
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #8391 Counter
1488
Since 4/2/2008
-
  Load Time=1 seconds.
 
Print This
-
 
Have a question? Need our services? Contact us now.
--Mike Prestwood

Call: 916-726-5675

email: info@prestwood.com


-
 
Connect With Us...
PrestwoodBoards
Join Us!
Facebook
Like our page!!!
Twitter
Follow us!
LinkedIn
Join Group
YouTube
View channel.
Go ahead!   Use Us! Call: 916-726-5675 


©1995-2014 Prestwood IT Solutions.   [Security & Privacy]   Made in the U.S.A..   No H1-B.   No offshoring.