🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #4233

Re: Database Transactions.

#4233
From: hugo
Date: Wed, 27 Feb 2002 11:41
46 lines
2187 bytes
If you use MSSQL, I can propose the following.
Try to make a stored procedure like this

CREATE PROCEDURE ps_What_Ever
AS
return SCOPE_IDENTITY()
GO
..........
Within the same transaction it should return the last inserted into the
identity column value.
Call this procedure each time after a record inserted.

I did not test this, have no time:))) It's just the first thing that came to
my head.

"Tony Forgan" <tony@wildlime.com> wrote in message news:3c7c1dfc_2@dnews...
> Hi,
>
> I am just wondering about Database Transactions. I have a case where I
need
> the ID of a newly created record in a table to be stored in another table,
> all during a transaction. Is this possible? At the moment it is not
> returning the new record's id.
>
> ie.
> DB->StartTransaction
>     Table2->Insert
>     ...
>     Table2->Post
>     id=Table2->FieldByName("ID")->AsInteger
>     Table1->FieldByName("Table2ID")->AsInteger=id
>     Table1->Post
>     DB->Commit
>
> Any help would be greatly appreciated.
>
> Thanks.
> --
> Tony Forgan - (B.I.T.)
> Systems Analyst
> Wild Lime - tony@wildlime.com
> Studio 1, 72 McLeod Street, Cairns 4870
> Web www.wildlime.com
> Tel 07 4081 6677 | Fax 07 4081 6679
>
>
Technical Details
Message-ID: <3c7cc5db_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!news.stealth.net!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.mesh.ad.jp!uunet!osa.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3c7c1dfc_2@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10698b,2ae92d6da780eff0
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2002-02-27 03:55:16 PST
Reply-To: "hugo" <hugo@valmi.com.ua>
From: "hugo" <hugo@valmi.com.ua>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3c7c1dfc_2@dnews>
Subject: Re: Database Transactions.
Date: Wed, 27 Feb 2002 13:41:14 +0200
Lines: 48
Organization: Valmi
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2462.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000
NNTP-Posting-Host: 80.91.160.110
Message-ID: <3c7cc5db_2@dnews>
X-Trace: dnews 1014810075 80.91.160.110 (27 Feb 2002 03:41:15 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!news.stealth.net!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.mesh.ad.jp!uunet!osa.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews