Page 1 of 1

Naming Conventions for Sequences and Triggers

Posted: Thu 22 Jan 2015 07:26
by jongleur
Hi.
I'm struggling with the SQL code Generation that is more or less inpredictable.

It generates Sequences and Triggers for Identity columns, which is what I want, but their names differ slightly.
Sometimes the sequence is called AI${SHORTENED_TABLENAME}_{Fieldname}_seq{someHash}, sometimes it's {TABLENAME}_seq instead.

It Looks like what's chosen might depend on the tables Name length and it's a strategy to keep the name short enough to be valid in an Oracle database context.

That's fine in General, but for some naming conventions defined by our customer we have predefined namings for database objects to comply on. With this, the Fieldname of the Primary key somehow replicates a short form of the table Name, thus a Sequence Name {Fieldname}_seq would be sufficient to be unique.
Of course due to that the length constraints are not met in my table namings.

How to achieve custom naming conventions for the SQL scripts?

A similar case are the Auto-Increment Triggers using those sequences.
For Triggers I get either the name AI${tablename} or {tablename}_INS_TRG, and I don't have any idea when each of those is chosen.

Is there any way to control how names are generated?

Kind regards
Peter

Re: Naming Conventions for Sequences and Triggers

Posted: Fri 23 Jan 2015 14:29
by Shalex
Here is a description of the designed behaviour for autogenerated triggers / sequences: http://forums.devart.com/viewtopic.php?t=22452.
You can also use custom-defined sequences via the devart:DefaultValue attribute in SSDL: http://blog.devart.com/set-identity-and ... ggers.html.
jongleur wrote:Sometimes the sequence is called AI${SHORTENED_TABLENAME}_{Fieldname}_seq{someHash}, sometimes it's {TABLENAME}_seq instead.
Please send us a small test project for reproducing the issue with generating a {TABLENAME}_seq sequence (instead of AI${TABLENAME}_{Fieldname}_seq).

Re: Naming Conventions for Sequences and Triggers

Posted: Fri 23 Jan 2015 14:42
by jongleur
Hi,

If I would have a clue about the conditions when the Sequence Name changes, I might be able to avoid that case and would not have a Problem at all.
That's why I doubt I'm able to send a test Project reproducing the Problem.
I stumbled over it several times in the last days, but don't know why, or under what circumstances.

Using custom defined sequences is nice, but does not allow to create those custom defined sequences from the model, so the SQL code generated by the model would contain the "Default" AI$-Sequence (obsolete as not used), a Trigger using the sequence referenced by the devart:DefaultValue, but not that sequence itself (missing, would be required).

I didn't test it yet, but apart from that: Is the devart:Default-Value compatible with a StoreGenerationPattern of COMPUTED or IDENTITY?
If not, the Default value would still allow the "user" of the .NET-Classes to manipulate the value by Hand, as a Default value is different from an auto-generated value overwritten in the Trigger.

regards
Peter

Re: Naming Conventions for Sequences and Triggers

Posted: Tue 27 Jan 2015 13:08
by Shalex
jongleur wrote:Using custom defined sequences is nice, but does not allow to create those custom defined sequences from the model
That is correct.
jongleur wrote:so the SQL code generated by the model would contain the "Default" AI$-Sequence (obsolete as not used), a Trigger using the sequence referenced by the devart:DefaultValue, but not that sequence itself (missing, would be required).
If you employ the devart:DefaultValue attribute, you can specify sequence with any name and no trigger will be used. See example (it includes the generated SQL): http://blog.devart.com/set-identity-and ... ml#example.
jongleur wrote:I didn't test it yet, but apart from that: Is the devart:Default-Value compatible with a StoreGenerationPattern of COMPUTED or IDENTITY?
Yes, it is.