Subject | Re: SV: SV: SV: [IBO] Refrasing my question about TIBOTable (prettyprinted) |
---|---|
Author | Thomas Steinmaurer |
Post date | 2011-05-17T08:39:26Z |
> CREATE SEQUENCE AddressNo_ADDRESS_GENYes it is, SQL script wise. The SELECT(MAX) statement simply is
> SET GENERATOR AddressNo_ADDRESS_GEN TO 180;
>
> Enough to create the generator and initialize it to 180?
responsible for getting the value 180. I guess this is something
specific to your data pump utility.
So, for a "final" SQL script, which is executable with e.g. Firebird's
isql command-line tool, remove the SELECT(MAX) ... statement.
--
With regards,
Thomas Steinmaurer
Upscene Productions
http://www.upscene.com
http://blog.upscene.com/thomas/
Download LogManager Series, FB TraceManager today!
Continuous Database Monitoring Solutions supporting
Firebird, InterBase, Advantage Database, MS SQL Server
and NexusDB!
> The script code that my pump makes looks like this:
>
> SELECT MAX(AddressNo) FROM ADDRESS
> CREATE SEQUENCE AddressNo_ADDRESS_GEN
> SET GENERATOR AddressNo_ADDRESS_GEN TO 180;
>
> And while I understand what the first line does in itself, my feeling here is that it is of no consequence to the making of the generator?
>
> Jacob
>
>
> Fra: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com] På vegne af Helen Borrie
> Sendt: 16. maj 2011 23:32
> Til: IBObjects@yahoogroups.com; IBObjects@yahoogroups.com
> Emne: Re: SV: SV: [IBO] Refrasing my question about TIBOTable (prettyprinted)
>
>
>
> At 07:26 AM 17/05/2011, Jacob Havkrog wrote:
>> Thanks!
>>
>> My triggers and the rest of the database generation script is produced by a datapump Delphi app, that I didn't write myself.
>>
>> I'll change the trigger generation code!
>>
>> In relation to this I have another question. The datapump app generates this SEQUENCE script code:
>>
>> SELECT MAX(AddressNo) FROM ADDRESS
>> CREATE SEQUENCE AddressNo_ADDRESS_GEN
>> SET GENERATOR AddressNo_ADDRESS_GEN TO 180;
>>
>> I'm just wondering if there is a bug here? The AddressNo generator is initialized to 180, which is the max AddressNo from my BDE database I'm pumping from. It works fine, but what's the point of the first part of the script code "SELECT MAX(AddressNo) FROM ADDRESS"? It looks wrong to me.
>
> Its purpose would be to find the highest autoinc value, since (like Firebird sequences/generators), the Paradox engine never generates the same autoinc number for a column.
>
> The sequence (a.k.a. generator) stores the last generated number. The next time a value is requested, that number is incremented by the specified increment value and the new number is stored for the next time. Generators (sequences), unlike everything else in Firebird, exist and are maintained independently from any user transaction.
>
> The pump is taking the max autoinc value from the Pdox table and hard-coding it, on the assumption that you will do this pump exactly once and will never create any more new ADDRESS records in Pdox.
>
> While this technique is OK for your one-off data conversion from Pdox to Fb, you should NEVER use a similar technique for incrementing key values in Firebird.
>
> Helen
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
>
> ___________________________________________________________________________
> IB Objects - direct, complete, custom connectivity to Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ___________________________________________________________________________
> http://www.ibobjects.com - your IBO community resource for Tech Info papers,
> keyword-searchable FAQ, community code contributions and more ! Yahoo! Groups Links
>
>
>