<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">Le 26/11/2013 16:02, Kovács László a
écrit :<br>
</div>
<blockquote
cite="mid:em72cb90a2-9746-43f1-aafa-6358c1322f4a@msi_noti"
type="cite">
<style id="eMClientCss">BLOCKQUOTE.cite {
BORDER-LEFT: #000000 1px solid; PADDING-LEFT: 10px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px
}
.plain PRE {
FONT-STYLE: normal; FONT-FAMILY: monospace; FONT-SIZE: 100%; FONT-WEIGHT: normal
}
.plain TT {
FONT-STYLE: normal; FONT-FAMILY: monospace; FONT-SIZE: 100%; FONT-WEIGHT: normal
}
BODY {
FONT-FAMILY: Tahoma; FONT-SIZE: 12pt
}
.plain PRE {
FONT-FAMILY: Tahoma; FONT-SIZE: 12pt
}
.plain TT {
FONT-FAMILY: Tahoma; FONT-SIZE: 12pt
}
</style><span class="plain">
<div>Hi dear list members. </div>
<div> </div>
<div>I'm new here. Approximately 17 years ago I worked as a
sysadmin, gave every day support for 70 peoples how to use
their computers. I also made numerous small apps, to help the
work of the firm. That time I did it with Delphi 1, used DBase
and Paradox tables. </div>
<div>I did this job for a few years, then the life pushed me
away from programming, but not too far away from computers. </div>
<div>Now I'm here, and seem to come back. </div>
<div>My friend wants me to create a database app, because the
task is just too complicated to do by himself in MS Access. </div>
<div> </div>
<div>I put my cents on Lazarus, as I can't afford any Delphi
(and like) available today. </div>
<div>I choosed Firebird (a very cost effective solution as well)
as database engine, started with embedded, but later when as
development progresses need move to real client-server. </div>
<div> </div>
<div>So, I created my database, that wasn't too hard with
IBExpert personal (I had to look for something to substitute
Database desktop). </div>
<div>I also managed to create my autoinc fields, using Firebirds
triggers and generators. Each of my tables has its own
counters. </div>
<div> </div>
<div>But I'm stuck with getting the newly inserted rows ID. </div>
<div>How do you get it? </div>
</span></blockquote>
Create as many sequences (new name for generators) as you need<br>
In the application when you need a new value for a sequence (an
insert for instance) I execute the next query just before:<br>
<b><i>select next value for my_generator_name as column_name_i_want
from rdb$database</i></b><br>
and I get the value with the query which executed the query (some
TQuery component, using FieldByName('column_name_i_want).AsInteger
or better AsLargeInt)<br>
The unique ID has been definitely reserved and the I can use it into
any other update or insert with other tables.<br>
This is my way but it not the only one but because I want to control
everything which reports to database, i'm used to this method<br>
<br>
Antonio.<br>
<blockquote
cite="mid:em72cb90a2-9746-43f1-aafa-6358c1322f4a@msi_noti"
type="cite"><span class="plain">
<div> </div>
<div>Or if you generate the ID on the client side, how do you
make absolutely sure, no other user can get the same ID. </div>
</span></blockquote>
That's easy: it is guaranteed by Firebirdwhatever way you choose<br>
<blockquote
cite="mid:em72cb90a2-9746-43f1-aafa-6358c1322f4a@msi_noti"
type="cite"><span class="plain">
<div> </div>
<div>Is there a way to ask Firebird about the next value of a
generator? And then I could use that ID upon an insert, and
would deactivate the triggers. </div>
</span></blockquote>
yes, read above, no need to deactivate or reactivate triggers<br>
<blockquote
cite="mid:em72cb90a2-9746-43f1-aafa-6358c1322f4a@msi_noti"
type="cite"><span class="plain">
<div> </div>
<div>If I'm on a wrong way with this ID thing, any other "Best
practices" are welcome. ;) </div>
<div> </div>
<div>I highly appreciate every help word! </div>
<div> </div>
<div>Thank you very much in advance </div>
<div> </div>
<div>Laszlo Kovacs </div>
</span>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">--
_______________________________________________
Lazarus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Lazarus@lists.lazarus.freepascal.org">Lazarus@lists.lazarus.freepascal.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus">http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus</a>
</pre>
</blockquote>
<br>
</body>
</html>