2. PLAN ESTRATEGICO DE VENTAS
2.5. Componentes de un Plan Estratégico de Ventas
2.5.3. Establecimiento de estrategias de ventas
IDENTITY Column Auto-Incrementing Support
A new numeric column attribute for auto-incrementing columns is now available. This feature is enabled with the IDENTITY SQL keyword.
Syntax exact_numeric_data_type :: TINYINT | SMALLINT | INTEGER | BIGINT | NUMERIC
| NUMBER [ ( precision [ , scale ] ) ] | DECIMAL [(precision, scale)]
| MONEY [(precision)]
[ IDENTITY [ ( ± seed , ± increment ) ] ]
IDENTITY
For TINYINT, SMALLINT, INTEGER and BIGINT column types, an optional auto-incrementing attribute can be defined with the IDENTITY option. This adds the column of the defined type to the table and automatically updates the value on each row insert.
The IDENTITY attribute by itself does not guarantee uniqueness of assigned values. Use a unique index to ensure unique values.
IDENTITY can optionally specify seed and increment values. seed is the starting assignment value and is incremented by increment for each update.
CREATE TABLE t1 (name CHAR(10), id_num INTEGER IDENTITY (0, 1));
Only one IDENTITY column can be defined per table. IDENTITY columns cannot be specified on tables with only one column.
IDENTITY values assigned to aborted rows in a table are lost. Note that this can result in gaps in the numerical sequence order.
IDENTITY is not supported for NUMERIC, NUMBER, DECIMAL or MONEY column types. IDENTITY cannot be added to an existing field via ALTER TABLE.
To return the current IDENTITY value in effect, the scalar function LAST_IDENT() can be called.
IDENTITY Support Added to c-treeDB
The following functions were added to the c-treeDB C API for working with Identity fields.
ctdbSetIdentityField
Set an Identity field for a table.
CTDBRET ctdbSetIdentityField(CTHANDLE Handle, pTEXT FieldName, CTINT64 seed, CTINT64 increment)
ctdbSetIdentityField() returns CTDBRET_OK on success or a c-tree error code on failure.
Note: You must call ctdbAlterTable() to persist the change to the table after this call.
ctdbGetIdentityFieldDetails
Retrieve the name, seed and increment of an Identity field.
pTEXT ctdbGetIdentityFieldDetails(CTHANDLE Handle, pLONG8 seed, pLONG8 increment)
ctdbGetIdentityFieldDetails() returns the Identity field name or NULL. For a NULL return, use
ctdbGetError() to verify if there was an actual error or if there is no identity field defined.
ctdbGetLastIdentity
Retrieve the last Identity value used for a table.
CTDBRET ctdbGetLastIdentity(CTHANDLE Handle, pLONG8 value)
ctdbGetLastIdentity() returns CTDBRET_OK on success or a c-tree error code on failure.
.NET Support
CTTable.SetIdentityField(table, seed, increment)
CTTable.GetIdentityFieldDetails(seed, increment)
CTTable.GetIdentityField()
CTTable.GetLastIdentity()
IDENTITY Columns Imported with the c-treeACE SQL Import Utility
c-treeACE SQL V9.3 introduced a new IDENTITY attribute for exact numeric columns. This support can be enabled on data files at the ISAM layer. The c-treeACE SQL Import utility has been enhanced to detect this attribute in existing tables and update the corresponding SQL system tables upon import.Sequence Numbers
Sequential numbering is a requirement for many applications. Accounting data is a particularly heavy application usage with respect to invoices, quotations, and other receivables and payables
documentation. c-treeACE offers several forms of automated numbering. The serial segment (SRLSEG) feature has long served this purpose. However, it suffers some limitations as it is an additional index overhead on a per-file basis. IDENTITY support is more flexible and performs better, although it is still limited to a single table. Consider global operations against multiple servers that require a single numbering scheme. This requires a persisted pool, and indeed, many c-treeACE applications have implemented their own unique solutions.
c-treeACE V10 introduces a generic method to create, maintain, and access multiple sources of sequential numbers through a new persisted Sequence feature.
c-treeACE Sequence Number Store
A sequence has the following properties associated with it:
sequence name
initial value
current value
limit value
incrementing or decrementing sequence
increment or decrement amount
cycling or terminating sequence
Changes are immediately committed to the sequence number. This includes creation and deletion of the sequence, as well as changing sequence settings and current values. A complete API is provided to manage this sequence number store.
Sequence Number API
ctCreateSequence() (page clvi)
ctDeleteSequence() (page clviii)
ctOpenSequence() (page clx)
ctCloseSequence() (page clxii)
ctGetSequenceAttrs() (page clxiv)
ctSetSequenceAttrs() (page clxvi)
ctGetCurrentSequenceValue() (page clxviii)
ctSetCurrentSequenceValue() (page clxx)
ctGetNextSequenceValue() (page clxxii)
The functions are listed in the Function Reference appendix in Sequence Number API (page clv). Attributes for each sequence are stored in a fixed-length record in the files SEQUENCEDT.FCS and SEQUENCEIX.FCS. c-treeACE creates these files when starting if they do not exist and these files are under full transaction control. An index on the sequence name field is used to find the record. Sequence values are stored as 64-bit values as shown in the ctSEQATTR structure definition.
Example
ctSEQATTR seqattr;
NINT rc;
/*
** Create an incrementing sequence that starts with 1, increments by 3, and ** terminates with 100.
*/
strcpy(seqattr.seqnam, "MyFirstSequence"); seqattr.seqini = 1;
seqattr.seqinc = 3; seqattr.seqlim = 100;
seqattr.seqtyp = ctSEQINC | ctSEQTRM | ctSEQLIM; if ((rc = ctCreateSequence(&seqattr))) {
printf("Error: Failed to create the sequence: %d\n", rc); } else {
printf("Successfully created the sequence.\n"); }
File Resource Fork - Direct Access Resource (DAR)
c-treeACE has long supported an ability to store “resource” records in a file. This resembles a similar approach taken by Apple Macintosh files that originally included both a “data” fork and a “resource” fork.
Resource forks store non-volatile data. Some people think of them as an “extended header” of a file. c-treeACE has supported “resource” forks for records to store various types of information including data schemas. However, in contrast to the main file header, these resources are not designed for high-speed access. A new design was required for fast access and updates.
To this end, a new special-purpose resource was introduced: the Direct Access Resource (DAR). The c-treeACE IDENTITY feature (auto-increment fields) takes advantage of this new feature and
experiences performance similar to the primary header portion of the file. This performance was not possible with the prior existing resource or SRLSEG index features.
If you encounter a situation where you need to store metadata in the resource portion of a file and require high-speed access, check out the new DAR support.
Note: Files created with c-treeACE post V9.2 include this DAR resource by default. Older
applications and utilities may not always recognize this new resource.